Search code examples
phplinuxsshcron

Setting up a new Cron to run a PHP file and nothing seems to happen


I'm sure this is fairly easy for someone to answer.

I have a dedicated server that had been setup by someone else previous to me and I need to set a new cron job. The cron will run a PHP file.

So far I have done the following:

  • sudo crontab -u root -e
    To edit the crontab. The last line before I added my line of code was a PHP script cron so I used that as example and changed the file path to my new file. See the two examples below, also I changed the cron to run every minute:

Old Example

 */5 * * * * /usr/bin/php /home/emailer/htdocs/admin/cron.php

New Code I added

 */1 * * * * /usr/bin/php /home/non-cms-websites/crons/cron-notifications/index.php

The script I have added just sends a test email to my email account use PHP Mailer, just a basic script at the moment but will have more functionality when I get it working.

Do I need to restart/reload the cron so the new one I added runs?

The server is running Linux Ubuntu 10.04 64 bit if that makes a difference.

Any help greatly appreciated, thank you.


Solution

  • Check the path to index.php file is correct or not. Also run crontab -l command to see the list of crons.