I have created a test instance of CiviCRM that uses Drupal 7 as the CMS. It's running inside a Ubuntu Desktop virtual machine that has a LAMP stack installed on it (Apache2, php7.2 and mySQL).

I am very new to Linux and would like to set up a cron job to run CiviCRM's scheduled tasks. I have looked at https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/, but I confess that I find it confusing. I haven't set up any cron jobs for Drupal, either. Can anyone help me, please?

Many thanks in advance,


1 Answer 1


Welcome to SE! Setting up cron can be confusing since there are many variations and it touches several aspects: OS users & permissions, CMS users & permissions, other tools, cron - and the details depend on your hosting environment.

I've just re-read the page you linked to. It has the information you need, but it also has other options that you don't need, so work through that step by step. (I've also submitted a few clarifications.)

So, following the 'Preparing' section and assuming a typical Ubuntu installation:

  1. Choose a command: I prefer the cv method
  2. OS User: Ubuntu typically uses 'www-data' to run Apache. (Adjust below if different.)
  3. CMS User: Create a Drupal user (eg 'cronuser') with the listed permissions

If you don't have cv installed already, go ahead and install it.

Check that you can run the command manually:

$ sudo -u www-data cv api job.execute --user=cronuser --cwd=/var/www/html

(If your installation is not under /var/www/html adjust accordingly)

Then add it to the crontab for www-data:

$ sudo crontab -e -u www-data
  • Thanks Aidan. That proved incredibly helpful. Commented Oct 17, 2019 at 14:35
  • Great! Now that you've gone through the process, if there are clarifications you can add to the documentation then do submit an update. It's easy to submit updates with the 'single change' method - docs.civicrm.org/user/en/latest/the-civicrm-community/…
    – Aidan
    Commented Oct 18, 2019 at 16:04
  • This is great and very clear. To install cv, I only had to issue two commands: sudo curl -LsS https://download.civicrm.org/cv/cv.phar -o /usr/local/bin/cv and sudo chmod +x /usr/local/bin/cv Commented Feb 7, 2020 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.