4

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

Oudin
  • 201

2 Answers2

6

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
0

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

/usr/local/bin/php /home/john/myscript.php
Peachy
  • 7,235
  • 10
  • 40
  • 47