Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

/etc/cron.d/username

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

2 Answers 2

up vote 4 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:

chmod +x YOURSCRIPT

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

OR

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
1  
@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

 
discard

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.