# HALF SOLVED: Good cron command line, nothing with cronjob

**URL:** <https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535>\
**Category:** Product Support\
**Created:** [May 28, 2020, 2:51pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535 "2020-05-28T14:51:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bulgin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bulgin/32/1001_2.png) [@bulgin](https://forum.mautic.org/u/bulgin)\
**Post date:** [May 28, 2020, 2:51pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535/1 "2020-05-28T14:51:11Z")

</div>

**Your software**  
My Mautic version is: v2.16.2 and Centos 7  
My PHP version is: 7.2.31

**Your problem**  
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[14905]: (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[14939]: (xxxxxt) CMD (/usr/bin/ea-php72 /home/xxxxx/public\_html/xxxxx/app/console mautic:emails:send \>/dev/null 2\>&1)

cron:

```
#SHELL=/bin/bash

* * * * * /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.

---

<div class="post-metadata">

**Author:** ![bulgin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bulgin/32/1001_2.png) [@bulgin](https://forum.mautic.org/u/bulgin)\
**Post date:** [May 28, 2020, 4:05pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535/2 "2020-05-28T16:05:50Z")

</div>

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. . .

---

<div class="post-metadata">

**Author:** ![bulgin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bulgin/32/1001_2.png) [@bulgin](https://forum.mautic.org/u/bulgin)\
**Post date:** [May 28, 2020, 5:18pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535/3 "2020-05-28T17:18:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![backseat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/backseat/32/1863_2.png) [@backseat](https://forum.mautic.org/u/backseat)\
**Post date:** [June 4, 2020, 3:45pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535/4 "2020-06-04T15:45:20Z")

</div>

Running cron jobs as root is best avoided where possible, if only from a “minimise risk” perspective.

Here’s what I would do:

- The `>/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 `www-data`:  
`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.

hth,  
Keith

---

<div class="post-metadata">

**Author:** ![bulgin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bulgin/32/1001_2.png) [@bulgin](https://forum.mautic.org/u/bulgin)\
**Post date:** [June 4, 2020, 4:04pm UTC](https://forum.mautic.org/t/half-solved-good-cron-command-line-nothing-with-cronjob/14535/5 "2020-06-04T16:04:44Z")

</div>

SOLVED:

Thanks, Keith.

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.
