Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I set up a php script to run via cron

I've created a file in the cron.d folder with the username as the file name:


Inside of username file I placed the following cron command

0,30 * * * *   username /home/username/public_html/cron.php

I'm actually trying to get the cron working for Open Atrium however upon checking Open Atrium status it shows no signs of the cron file being run.

Any help on this would be greate

share|improve this question
up vote 5 down vote accepted

You can use crontab to add/remove/edit cronjobs.

Hit Alt+Ctrl+T to open terminal.

First make sure the script is executable by running:


Then run the following command to add your cronjob:

crontab -e

Add your cronjob like this:

0,30 * * * * /usr/local/bin/php /home/username/public_html/cron.php

That's it!

Your can check the current user's crontab entries by running:

crontab -l

For more information about crontab run:

crontab --help


man crontab
share|improve this answer
I still haven't gotten it to work. Question my /usr/local/bin/ folder is empty is this normal? I'm using php5-cgi – Oudin Aug 20 '12 at 23:39
@Oudin try /usr/bin/php-cgi. You can search binary packages installed on your system by running whereis -b <PackageName>, In your case whereis -b php-cgi – Basharat Sialvi Aug 21 '12 at 9:54
Thanks just found it a few hours ago but goggling php-cgi location – Oudin Aug 21 '12 at 13:56

Don't you also have to put the path to php?

/usr/local/bin/php /home/john/myscript.php
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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