# Cronjob not working on mautic 3.0.1

**URL:** <https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [July 5, 2020, 2:18am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083 "2020-07-05T02:18:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![batarchi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/batarchi/32/547_2.png) [@batarchi](https://forum.mautic.org/u/batarchi)\
**Post date:** [July 5, 2020, 2:18am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/1 "2020-07-05T02:18:12Z")

</div>

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

 ![Screenshot_148](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/a/a61b582f5d6549ffcbe4319c65d64f277449970a.png)

---

<div class="post-metadata">

**Author:** ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)\
**Post date:** [July 6, 2020, 8:51am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/2 "2020-07-06T08:51:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![batarchi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/batarchi/32/547_2.png) [@batarchi](https://forum.mautic.org/u/batarchi)\
**Post date:** [July 6, 2020, 3:37pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/4 "2020-07-06T15:37:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![batarchi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/batarchi/32/547_2.png) [@batarchi](https://forum.mautic.org/u/batarchi)\
**Post date:** [July 8, 2020, 7:44pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/5 "2020-07-08T19:44:23Z")

</div>

![Screenshot_161](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/e/e615e2ae73a562945d8749898e4a1aa00200e0b2.png) cron log

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [July 14, 2020, 1:44pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/6 "2020-07-14T13:44:14Z")

</div>

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](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](https://docs.mautic.org/en/setup/cron-jobs)

---

<div class="post-metadata">

**Author:** ![jeremyhyde](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jeremyhyde/32/2806_2.png) [@jeremyhyde](https://forum.mautic.org/u/jeremyhyde)\
**Post date:** [August 1, 2020, 2:49pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/7 "2020-08-01T14:49:54Z")

</div>

> [@stefanomarty](#):
>
> 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/

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.

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [August 2, 2020, 12:47pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/8 "2020-08-02T12:47:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 2, 2020, 6:29pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/9 "2020-12-02T18:29:28Z")

</div>

> [@stefanomarty](#):
>
> app/cache and app/logs folders to var/ with v.3.0.0+  
> sudo -s

Hello everyone,

I have the same problem as batrachi but as a newbie, I don’t know how to modify the :

app/cache and app/logs folders to var/ with v.3.0.0+  
sudo -s

if anyone can tell me how to do this I will be grateful.

thank you

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 2, 2020, 11:33pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/10 "2020-12-02T23:33:17Z")

</div>

> [@zkichou](#):
>
> I have the same problem as batrachi but as a newbie, I don’t know how to modify the :
> 
> app/cache and app/logs folders to var/ with v.3.0.0+  
> sudo -s

You’re right, that was just a quick hint quite obscure. When I wrote that post, the instructions given in the article:  
[https://docs.mautic.org/en/troubleshooting/file-ownership-and-permissions](https://docs.mautic.org/en/troubleshooting/file-ownership-and-permissions)

were referring to the wrong folders (app/cache and app/logs) instead of the new ones defined from version 3.0.0 and above (var/cache and var/logs).

The instructions look correct now, so you can just follow them.

I’m assuming you have ssh access and sudo permission to root. You also need to know the “path/to/mautic” folder where Mautic is installed (that’s “/var/www/html/mautic/” in my server). It’s easier if you save that path in a shell variable, like “mauticPATH”. The complete set of commands is:

```auto
sudo -s
mauticPATH=/var/www/html/mautic/
chown -R www-data:www-data ${mauticPATH}
cd ${mauticPATH}
find . -type d -not -perm 755 -exec chmod 755 {} +
find . -type f -not -perm 644 -exec chmod 644 {} +
chmod -R g+w ${mauticPATH}var/cache/
chmod -R g+w ${mauticPATH}var/logs/
chmod -R g+w ${mauticPATH}app/config/
chmod -R g+w ${mauticPATH}media/files/
chmod -R g+w ${mauticPATH}media/images/
chmod -R g+w ${mauticPATH}translations/

```

Then you need to change the /etc/crontab file:

```auto
vim /etc/crontab

```

Add the crontab jobs for the www-data user:

```auto
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

```

You can also add some optional jobs (uncomment the desired ones):

```auto
02,17,32,47 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send >>/var/www/html/mautic/var/logs/cron.log 2>&1
#07,22,37,52 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:fetch
#08,23,38,53 * * * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:social:monitoring
#
0 0 7 * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:iplookup:download >>/var/www/html/mautic/var/logs/cron.log 2>&1
#0 0 2 * * www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:maintenance:cleanup --days-old=365 >>/var/www/html/mautic/var/logs/cron.log 2>&1

```

Add " \>\>/var/www/html/mautic/var/logs/cron.log 2\>&1" to save the job output a log file instead of receiving it by email.

Again, I’m assuming you can run php with “/usr/bin/php”. You can check it with this command:

```auto
which php

```

Hope the above helps.

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 9:04am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/11 "2020-12-03T09:04:12Z")

</div>

thnx a lot @stefanomarty

i have already the permission

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/d/d8cbb18b018c9af2718972b12f06e84de49b37a0.png)

here is my cronjobs on /etc/crontab folder

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/b/b855eb037338fc0e18edb310ba3fe555056f97d9.png)

but on mautic nothing is working !!!

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 3, 2020, 9:34am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/12 "2020-12-03T09:34:32Z")

</div>

Ok no panic 🙂

Permissions look fine. First of all, what do you mean by “_on mautic nothing is working_”? I thought your issue was just about making the crontab jobs run, is that correct?

Do the crontab jobs run if you launch the commands manually? I mean, what happens if you run this commands from your terminal:

```auto
sudo -u www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:segments:update
sudo -u www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:update
sudo -u www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:trigger

```

Do you see any error? How about Mautic web interface, is it running ok?

Mautic is quite a complex platform, you’ll need to follow the instructions step by step (see link in previous post).

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 10:31am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/13 "2020-12-03T10:31:06Z")

</div>

my appologise, I didn’t explain my situation well

on mautic, the manual controls work but not the auto one,

e.g.: I created a simple campaign (sergment) =\> send email

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6b7a2e7fa73553341283bb9c49dc96ca5e9968bd.png)

when I add my emails (3) to the segment, the campaign don’t send the emails

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/610e9caca2a399b57f83e7b25d559a8e894aae5b.png)

here my mannual commandes

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/3/3d13801d8349e38eaab23f1be666bbbdd2600340.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/7/7694c770327dca63ac06d00b5453f4c8f161b4ec.png)

must i change something in the mautic general setting !!

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/1/1d8d0780ab8cbf8856e8db1c69e45b886a425714.png)

thnx again 🙂

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 3, 2020, 10:48am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/14 "2020-12-03T10:48:56Z")

</div>

Looks like you have no contacts added to the segment.

Could you post the “Segment” screenshot of your system? Something like this:

 ![Schermata 2020-12-03 alle 11.43.31](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/c0b2a0fdf1023e38ba131a29e7e977ce61007a3f.png)

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 11:19am UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/15 "2020-12-03T11:19:21Z")

</div>

my emails for the test

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/8/84e821e1466192b089bb0e6f6ff03155a4507454.png)

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 3, 2020, 2:03pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/16 "2020-12-03T14:03:56Z")

</div>

Ok, so the contacts where already added to segment #8, good.

It’s not easy to see what’s happening there, I would check the following:

- Configuration --\> Email Settings: is test connection ok? can you send the test email?
- Email handling: is it set to “send immediately” or “queue”?
- If set to “queue”, have you tried sending the queue manually with the command:

```auto
sudo -s www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send

```

What’s the command output? What do you see in the log?

If all the above is ok, there’s probably a constrain somewhere else preventing the emails to be sent.

We need somebody else involved here, as this is probably beyond my level of Mautic expertise (which is very low 🙂)

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 2:28pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/17 "2020-12-03T14:28:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/4f2794461c9b7e5d61f786226ce734f1dbc7db32.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/2/2caab9e3c75bfff613136b4af8f344805ac1db83.png)

i creat an queue email on the campaign

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/0/000445966eaf839e56859f8729d44c13da115c9e.png)

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 2:47pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/18 "2020-12-03T14:47:32Z")

</div>

can i know what u have in ur mautic general setting ??

I’ve changed everything, so I don’t know if the path is good or not.

and how can I be sure it’s good???

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/0/0c9ad96c1ab153198fd66dffbdd0677c317ce266.png)

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 3, 2020, 3:01pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/19 "2020-12-03T15:01:05Z")

</div>

Sorry, my fault, the correct command is:

```auto
sudo -u www-data /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send

```

That’s “-u”, not “-s”

Anyway if you set the configuration to send email immediately you don’t need to elaborate the queue, emails should be sent without the cron job.

Don’t know what to say at this point, you need to check every step, see if your smtp service receives the emails, check the logs, etc.

---

<div class="post-metadata">

**Author:** ![zkichou](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zkichou/32/646_2.png) [@zkichou](https://forum.mautic.org/u/zkichou)\
**Post date:** [December 3, 2020, 3:08pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/20 "2020-12-03T15:08:39Z")

</div>

if the manually commande work, so we are sure that the prob is the cronjobs no ???

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/0/0792443de79babeaf002e8efc7bbab2d6d28ed85.png)

---

<div class="post-metadata">

**Author:** ![stefanomarty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stefanomarty/32/690_2.png) [@stefanomarty](https://forum.mautic.org/u/stefanomarty)\
**Post date:** [December 3, 2020, 3:11pm UTC](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083/21 "2020-12-03T15:11:40Z")

</div>

Wait, the “cache” folder is in “var”, not in “bin”!  
I have the “mautic folder” in /opt instead of /var/www/html, but that makes no difference (as long as you put the correct folder in your crontab jobs):

 ![Schermata 2020-12-03 alle 16.03.47](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/5/5d674c6855a44136a595279c9455bc83680589e7.png)

Check your install with:

```auto
sudo -s
mauticPATH=/var/www/html/mautic/
cd ${mauticPATH}
ls -la var
# Here you should see the cache folder among others:
# drwxr-xr-x 6 www-data www-data 4096 Jun 29 20:06 ./
# drwxr-xr-x 11 www-data www-data 4096 Dec 3 07:52 ../
# drwxrwxr-x 5 www-data www-data 4096 Dec 3 07:52 cache/
# -rw-r--r-- 1 www-data www-data 14 Jun 29 20:04 .htaccess
# drwxrwxr-x 2 www-data www-data 4096 Dec 3 15:41 logs/
# drwxr-xr-x 2 www-data www-data 4096 Jul 15 09:57 spool/
# drwxr-xr-x 4 www-data www-data 4096 Dec 3 07:52 tmp/
#

```

```auto
ls -la bin
# Here you'd see something like this:
# drwxr-xr-x 2 www-data www-data 4096 Dec 3 07:52 ./
# drwxr-xr-x 11 www-data www-data 4096 Dec 3 07:52 ../
# -rw-r--r-- 1 www-data www-data 1528 Dec 3 07:52 console
# -rw-r--r-- 1 www-data www-data 13 Dec 3 07:52 .htaccess

```

[Next page](https://forum.mautic.org/t/cronjob-not-working-on-mautic-3-0-1/15083.md?page=2)
