Error when triggering cron job commands manually

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:

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

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

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:

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

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

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

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

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

How often is your cron triggering this command?

every 5 mins

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

Now the corn job is running fine.

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.