# Error when triggering cron job commands manually

**URL:** <https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [April 18, 2022, 1:08pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778 "2022-04-18T13:08:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaniss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/yaniss/32/592_2.png) [@yaniss](https://forum.mautic.org/u/yaniss)\
**Post date:** [April 18, 2022, 1:08pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/1 "2022-04-18T13:08:38Z")

</div>

Mautic v4.2.1  
PHP Version 7.4.28

Hello all,

I have been trying to set up my cron jobs and can’t manage to do so. I also can not figure how to trigger commands manually just to make sure my cron path would be correct.

By looking around, I found that this line should be triggering the sending of emails correctly:

```auto
php home/bitnami/stack/mautic/bin/console mautic:emails:send

```

However, I am getting hit with some errors that I can not solve alone.

```auto
PHP Warning: fopen(/opt/bitnami/mautic/var/cache/prod/../run/sf.mautic-emails-send.f8887da39a17dfb1ee96a61884260c394951b7a56925ffc98f03399e9f5028fa.lock): failed to open stream: Permission denied in /opt/bitnami/mautic/app/bundles/CoreBundle/Command/ModeratedCommand.php on line 151
PHP Warning: flock() expects parameter 1 to be resource, bool given in /opt/bitnami/mautic/app/bundles/CoreBundle/Command/ModeratedCommand.php on line 152
Failed to lock /opt/bitnami/mautic/var/cache/prod/../run/sf.mautic-emails-send.f8887da39a17dfb1ee96a61884260c394951b7a56925ffc98f03399e9f5028fa.lock.
Script in progress. Can force execution by using --bypass-locking.

```

No logs are being registered in Mautic itself  
These are the commands variations that I have tried as it looked like maybe a permission issue:

```auto
sudo php home/bitnami/stack/mautic/bin/console mautic:emails:send
sudo php home/bitnami/stack/mautic/bin/console mautic:emails:send --bypass-locking

```

However, while they don’t create errors, no pending emails from my Mautic instance is getting sent.

Does anyone have any idea how I can make this one work?

I’m also curious if this cron job would be correct if the command above was working or if there’s anything I should add:

- 
  - 
    - 
      - 5 php home/bitnami/stack/mautic/bin/console mautic:emails:send

Thank you for your time

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 19, 2022, 8:08am UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/2 "2022-04-19T08:08:50Z")

</div>

Hi,  
when you go to `/var/spool`  
and do a `ls -la` command, do you see emails stuck with weird extensions, like “.sending” ?  
Joey

---

<div class="post-metadata">

**Author:** ![anilb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anilb/32/6472_2.png) [@anilb](https://forum.mautic.org/u/anilb)\
**Post date:** [April 21, 2022, 10:02am UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/3 "2022-04-21T10:02:43Z")

</div>

I am facing the same issue.  
When I try to run the cornjob “/bin/console mautic:emails:send”  
it throws below warning  
script with pid 3306 in progress

/var/spool

has files with .message for last two days

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 21, 2022, 10:32am UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/4 "2022-04-21T10:32:44Z")

</div>

Hi, it means your system is stuck with sending.  
The script is running in the background and the sending doesn’t happen.  
This can be caused when you are running sending commands without waiting the previous one to finish.  
There are many ways to investigate this based on your skill level, but restarting the server might be the simpliest.

The email send will resume once the crons kick in again, but the problem is not solved.  
Joey

---

<div class="post-metadata">

**Author:** ![anilb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anilb/32/6472_2.png) [@anilb](https://forum.mautic.org/u/anilb)\
**Post date:** [April 21, 2022, 12:03pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/5 "2022-04-21T12:03:35Z")

</div>

I ran this script to clear all message from spool  
/bin/console swiftmailer:spool:send

Now the spool folder is empty. Around 2800 emails have gone.

The problem is due to mautic send corn job is throwing error  
/bin/console mautic:emails:send

"Script with pid 3306 in progress "

when I force the corn job, it works fine.  
/bin/console mautic:emails:send -f

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 21, 2022, 12:43pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/6 "2022-04-21T12:43:28Z")

</div>

> [@anilb](#):
>
> /bin/console mautic:emails:send

How often is your cron triggering this command?

---

<div class="post-metadata">

**Author:** ![anilb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anilb/32/6472_2.png) [@anilb](https://forum.mautic.org/u/anilb)\
**Post date:** [April 21, 2022, 1:47pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/7 "2022-04-21T13:47:48Z")

</div>

every 5 mins

---

<div class="post-metadata">

**Author:** ![anilb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anilb/32/6472_2.png) [@anilb](https://forum.mautic.org/u/anilb)\
**Post date:** [April 21, 2022, 2:08pm UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/8 "2022-04-21T14:08:30Z")

</div>

I have killed the SQL pid by command “kill -9 3306”

Now the corn job is running fine.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 22, 2022, 8:00am UTC](https://forum.mautic.org/t/error-when-triggering-cron-job-commands-manually/23778/9 "2022-04-22T08:00:39Z")

</div>

Do you wonder what happens after 5 minutes and your cron is not finished with 2800 emails? I think you start to have problems. I would limit the emails sent by the cron in a way that it can do it’s job.

You can use one of these commands also for limits:

–message-limit[=MESSAGE-LIMIT]  
Limit number of messages sent at a time. Defaults to value set in config.

–time-limit[=TIME-LIMIT]  
Limit the number of seconds per batch. Defaults to value set in config.
