-1

I'm running a CentOS 5 server, and trying to schedule a job which runs a php file every day at the same time, I've added a new file to the directory

/etc/cron.d/

called get_files

The get_files file contains the following:

03 6 * * * php /var/www/html/get-info.php

However, the above job doesn't seem to get run. What am I doing wrong?

2
  • That is an excellent canonical answer. It probably covers every cron-related question we've ever had here.
    – Ladadadada
    Apr 6, 2013 at 17:55
  • @Ladadadada: It is now, the $original was full of $fail.
    – user9517
    Apr 7, 2013 at 16:33

2 Answers 2

1

you should use the full path to php, and use the -f switch

03 6 * * * /path/to/php -f /var/www/html/get-info.php
2

The cron jobs in /etc/cron.d/ (and also /etc/contab) have six parts before the command, not five. The first five are as you expect, the schedule. The sixth is the user the command should run as.

Cron files often have explicitly set variables such as SHELL and PATH which avoids requiring full paths to everything in the rest of the cron file.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
03 6 * * * root php /var/www/html/get-info.php

Your original cron job would have been logging an error in /var/log/cron saying that it couldn't find the user "php".

0

Not the answer you're looking for? Browse other questions tagged .