My Mautic version is: v2.16.2 and Centos 7
My PHP version is: 7.2.31
My problem is:
Cron jobs run by copying and pasting cronjob contents on command line but not with cron job itself. Just stopped working upgrading 2.16.2
Date to publish is in the past.
/spool/default directory contains the patiently waiting emails that are waiting to be sent.
cron log shows:
May 28 10:42:01 xxxxx CROND: (xxxxxt) CMD (/usr/bin/ea-php72 /home/xxxxx/public_html/xxxxx/app/console mautic:broadcast:send >/dev/null 2>&1)
May 28 10:43:01 xxxxx CROND: (xxxxxt) CMD (/usr/bin/ea-php72 /home/xxxxx/public_html/xxxxx/app/console mautic:emails:send >/dev/null 2>&1)
* * * * * /usr/bin/ea-php72 /home/xxxxxx/public_html/xxxxxx/app/console mautic:emails:send >/dev/null 2>&1
*/3 * * * * /usr/bin/ea-php72 /home/xxxxx/public_html/xxxxx/app/console mautic:broadcast:send >/dev/null 2>&1
10,25,40,55 * * * * /usr/bin/ea-php72 /home/xxxxx/public_htmlxxxxx/app/console mautic:campaigns:trigger >/dev/null 2>&1
5,20,35,50 * * * * /usr/bin/ea-php72 /home/xxxxx/public_html/xxxxx/app/console mautic:campaigns:update >/dev/null 2>&1
0,15,30,45 * * * * /usr/bin/ea-php72 /home/xxxxx/public_html/xxxxx/app/console mautic:segments:update >/dev/null 2>&1
Any help much appreciated.
installing the command line to the root cronjob swept all the waiting emails out of the default folder.
Now I’m scratching my head why is that? All the folders and directories in Mautic are owned by user not root. . .
Is it safe to run cronjobs for Mautic using root privileges? I can’t get the user under which Mautic is running and installed to execute any cron jobs but they all run fine under root cronjobs?
Running cron jobs as root is best avoided where possible, if only from a “minimise risk” perspective.
Here’s what I would do:
>/dev/null near the end of each cron line means “discard any output from this command”. The
2>&1 means “send any errors to the same place as the other output”. In other words, all information, errors, warnings, etc, are being lost. The first thing I’d do is remove
>/dev/null 2>&1 from the end of every cron line.
- Those commands should run as the web user, but the actual username will depend upon which Linux distribution you are using. For example, on Debian and Ubuntu, it’s
www-data by default, but it could be different on your system. Find out what username your web server runs under. If you need help to do that, ask .
- Switch to the web server user. For simplicity, let’s assume that’s
su -s /bin/bash www-data
That says “switch user, with /bin/bash as the shell, to user www-data”
- Try to run your cron command. For example:
/usr/bin/ea-php72 /home/xxxxxx/public_html/xxxxxx/app/console mautic:emails:send
That will probably fail, but it should output some useful information. Copy and paste that here if you’re not sure what to do next.
The problem was that within `/etc/crontab there was a cron job setup. Since I can’t find a way to delete that job, I commented out that entry with # and not the cron jobs run as they should. As well there is a cronjob in /var/spool/crontab which I also could not delete but which I was able to comment out.
I’m on Centos and if any one knows why a job was created in /var/spool/crontab, and more importantly, how to remove that job, I would be thankful.