# How to implement cronjobs

**URL:** <https://forum.mautic.org/t/how-to-implement-cronjobs/16896>\
**Category:** Product Support\
**Created:** [November 6, 2020, 11:31am UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896 "2020-11-06T11:31:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [November 6, 2020, 11:31am UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896/1 "2020-11-06T11:31:36Z")

</div>

**Your software**  
My Mautic version is: 3.1.2  
My PHP version is: 7.3  
My Database type and version is: 5.7

**Your problem**  
I’d like to know how and which cronjobs to implement? I installed Mautic on-premise on an Debian 10 virtual host running Apache 2.4  
I know there i need to trigger some executions via CRON to let the system execute several tasks.  
But what user should run it? Is it “root” or “www-data” or a special “mautic” user?  
And how to add the lines into /etc/cron.d/… file? Those tables are very picky about what the task do and will also emit local emails if the execution outputs any results.

From the examples i took this kind of execution:  
`0,15,30,45 * * * * root /usr/bin/php /systems/mautic/htdocs/app/console mautic:segments:update 5,20,35,50 * * * * root /usr/bin/php /systems/mautic/htdocs/app/console mautic:campaigns:update 10,25,40,55 * * * * root /usr/bin/php /systems/mautic/htdocs/app/console mautic:campaigns:trigger 10,25,40,55 * * * * root /usr/bin/php /systems/mautic/htdocs/app/console mautic:messages:send 10,25,40,55 * * * * root /usr/bin/php /systems/mautic/htdocs/app/console mautic:emails:send`

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [November 6, 2020, 12:03pm UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896/2 "2020-11-06T12:03:46Z")

</div>

Hey

You can run cron as root or www-data.

Easiest way is to type in crontab -e

and check out this link for all the cronjob available and required: [https://docs.mautic.org/en/setup/cron-jobs](https://docs.mautic.org/en/setup/cron-jobs)

---

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [November 6, 2020, 3:33pm UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896/3 "2020-11-06T15:33:19Z")

</div>

Thanks mike, i’ve already seen this. But the way a user-crontab works is slightly different than in /etc/cron.d/ on the Linux side.  
Running as www-data does not work (produces lot’s of errors), so i currently run them manually as root. But maybe root is a bit too highleved for this tasks?!

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [November 7, 2020, 5:53pm UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896/4 "2020-11-07T17:53:04Z")

</div>

I run mine as root. Not sure about the pro’s or cons of it, but works for me 😃

---

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [November 8, 2020, 5:30pm UTC](https://forum.mautic.org/t/how-to-implement-cronjobs/16896/5 "2020-11-08T17:30:48Z")

</div>

Ok, i’ll do the same. Was just a bit unshure if that it the proposed way to do. Usually webapps written in PHP do not need that high access and most often running a webapp once as user and as root could end up in deadlocks because user can’t remove/overwrite things written by root.

So i suggest if running as www-data (my local Apache 2 user) is working, it was sufficient.
