Mautic Community Forums

How to check Mautic cron jobs inside Docker container

Your software
My Mautic version is: 2.16.2
My PHP version is: 7.1.33
My Database type and version is: Percona MySQL 5.7

Your problem
My problem is: How do I check if the Mautic cron jobs are running?

I’ve installed Mautic via Docker. I entered the container but am not able to verify if the Mautic cron jobs are running.

It looks like the cron jobs are set in /etc/cron.d/mautic

Sample:
8,23,38,52 * * * * www-data php /var/www/html/app/console mautic:segments:update > /var/log/cron.pipe 2>&1

but I don’t see any logs written to /var/log/cron.pipe. Does this confirm that the cron jobs are not running?

I’ve also tried running crontab -l and crontab -u www-data -l , but it just says no crontab.

If the jobs are not running, how do I get them to run? And what commands can I use thereafter to check that the jobs are running properly?

Thank you.
Jen

Hello @hhjchen ,

I’m currently having the same trouble as you, with a couple of differences, being: I installed version 4 of Mautic using Mautic’s official image; I use a self-hosted MySQL server on a different server and connected it to my Mautic using environment variables; I use Amazon SES for my email service.

I have configured my Mautic to enable more than one email to be sent to every contact in the “Default Frequency Rule” and I’ve also set the email sending scheme to use Queue in the “Mail Send Settings” configuration.

I confirmed that the container’s crontab is non-existent by docker exec-ing into the container and running crontab -e. I checked that the cron jobs are also defined in /etc/cron.d/mautic.

I also confirmed that the installation is not faulty because I sent a couple of emails using the “Send Immediately” option for the “Mail Send Settings” and the emails did get sent out.

I can confidently say that the problem stems from the cron job because after setting the “Mail Send Settings” to queue and I tried sending a couple of emails, the emails are created and stored in the var/spool/ directory in the form of file_name.message files inside the container. The problem is that they’re not getting sent out.

I tried manually running php /var/www/html/bin/console mautic:emails:send from the /var/www/html directory and nothing happened, the emails are still intact in the var/spool/ directory.

I’m curious, have you figured out a solution to this problem? If you have, do you mind sharing your solution?

Thank you very much,
Ibnu

So after a week of tinkering, I found the problem.

The problem is in one of the cron command in the /etc/cron.d/mautic file. According to this post in Mautic’s github repo, the @reboot command doesn’t seem to work. Why? Frankly I haven’t done my research as to why. But after removing that line and adding news lines after every command, my cron works. Here is the complete cron commands:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

* * * * *     www-data   php /var/www/html/bin/console mautic:segments:update > /var/log/cron.pipe 2>&1

*/5 * * * *     www-data   php /var/www/html/bin/console mautic:import > /var/log/cron.pipe 2>&1

* * * * *     www-data   php /var/www/html/bin/console mautic:campaigns:rebuild > /var/log/cron.pipe 2>&1

* * * * *     www-data   php /var/www/html/bin/console mautic:campaigns:trigger > /var/log/cron.pipe 2>&1

* * * * *     www-data   php /var/www/html/bin/console mautic:messages:send > /var/log/cron.pipe 2>&1

* * * * *     www-data   php /var/www/html/bin/console mautic:emails:send > /var/log/cron.pipe 2>&1

0,15,30,45 * * * *     www-data   php /var/www/html/bin/console mautic:email:fetch > /var/log/cron.pipe 2>&1

0,15,30,45 * * * *     www-data   php /var/www/html/bin/console mautic:social:monitoring > /var/log/cron.pipe 2>&1

0,15,30,45 * * * *     www-data   php /var/www/html/bin/console mautic:webhooks:process > /var/log/cron.pipe 2>&1

0,15,30,45 * * * *     www-data   php /var/www/html/bin/console mautic:broadcasts:send > /var/log/cron.pipe 2>&1

         * 1 * * *     www-data   php /var/www/html/bin/console mautic:maintenance:cleanup --days-old=365 > /var/log/cron.pipe 2>&1

        0 4 15 * *     www-data   php /var/www/html/bin/console mautic:iplookup:download > /var/log/cron.pipe 2>&1

       */5 * * * *     www-data   php /var/www/html/bin/console mautic:reports:scheduler > /var/log/cron.pipe 2>&1

        0 5 10 * *     www-data   php /var/www/html/bin/console mautic:unusedip:delete > /var/log/cron.pipe 2>&1

Hope this could be useful for future readers.
Cheers!