Mautic Community Forums

Cronjob not working on mautic 3.0.1

Your software
My Mautic version is:3.0.1
My PHP version is:7.3

Your problem
My problem is: corn job not working
I’m trying to import contacts in the background but nothing happens
These errors are showing in the log:

Steps I have tried to fix the problem: fresh install and clean the cash and change the directory to bin/console instead of app/console
this is my setting

What happens if you run some commands manually? E.g. /var/www/html/mautic/bin/console mautic:campaigns:update? Do you see any errors or does the process complete successfully?

yes the process complete successfully i tried running commands is working fine no errors, but te corn not working automatically

cron log

It could be a permissions issue: which http engine are you using?

With Apache, try resetting the permissions to www-data and then execute the cron job as www-data, not root.

See the main article here:
https://docs.mautic.org/en/troubleshooting/file-ownership-and-permissions

You’ll have to change the app/cache and app/logs folders to var/ with v.3.0.0+
sudo -s
chown -R www-data:www-data /var/www/html/mautic
cd /var/www/html/mautic
find . -type d -not -perm 755 -exec chmod 755 {} +
find . -type f -not -perm 644 -exec chmod 644 {} +
chmod -R g+w var/cache/ var/logs/ app/config/
chmod -R g+w media/files/ media/images/ translations/

and then change the crontab file to use ww-data (or assign those tasks to www-data user crontab):
00,15,30,45 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:segments:update
05,20,35,50 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:update
10,25,40,55 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:trigger

I’d follow this suggestion as well:
It is HIGHLY recommended that you stagger the following required jobs so as to not run the exact same minute.

as seen here:
https://docs.mautic.org/en/setup/cron-jobs

Thanks for your post. It was extremely helpful and got my cron jobs sorted out. I had spent a lot of the last few days reading through sites and posts, most of which referred to mautic version 2 and their suggestions did not fit to the current version or did not work. Your suggestion to change the permissions as per the earlier mautic guide and providing the updated commands along with www-data user worked fine.

1 Like

I’m glad it helped!

I had a similar issue and it took a while to figure out the cronjob, running as root, was making a mess out of the Mautic permissions.