Cronjob not working

Your software
My Mautic version is: 3.3.3
My PHP version is: 7.4
My Database type and version is:

Your problem
My problem is: Cronjob not working

I have installed Mautic on Ubuntu 21 and now i’m stuck at cronjob, my campaigns action is always pending. My cronjobs:

And i think it’s running but campaigns is not triggered:

When i run the command manually, it’s working perfectly:

I’ve already do as stefanomarty said in this post but still no luck:

I have been trying for days, please help me.

UPDATE: This is my /var/logs/prod-2021-08-14.php file:
console.ERROR: Error thrown while running command “'mautic:campaigns:trigger '”. Message: "Command "mautic:campaigns:trigger " is not defined. Did you mean one of these? mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:trigger

This’s how I solved my cron on ubuntu with cyberpanel

Use sudo su

Crontab -e

Paste your crontab

5 * * * * php path/to/mautic/bin/console mautic:import

What was that for? How is it going to solve my problem? I don’t need to import contacts. Did you answer without looking at the question?

Please don’t follow this advice to add to the root crontab. If anything you need to do ‘sudo su - www-data -s /bin/bash/‘ before editing the crontab.

I have had issues with crons firing though and I have used systemd with timers instead which works really well. I’ll post an example config later. It’s really cool because you can add amounts of randomness to the timers to mitigate the chance that jobs are running simultaneously.

If you search for “systemd replace cron” you would get good results.

1 Like

Thank you for answering, i really appreciate that.
I’ve finally solved the problem: My crontab is being saved with DOS format, so it will put ^M as newline ending and it will cause problem. When saving the crontab find using nano, i need to to press Alt + M to switch to MAC format, so that it will save the file Unix format.