2

I am trying to run a cron job in Linux with following command:

crontab -e

typing the following details and saving it

MAILTO="[email protected]"
00 01 * * * /usr/local/bin/php /var/www/html/cron.php > /dev/null 2>&1

I am saving this cron job. But it's not running; I'm not getting any output in mail. I don't know how to get details of the cron job which ran. Or is there a better way to run the cron job?

1 Answer 1

8

The cron job you pasted will run at 1am daily, and the > /dev/null 2>&1 part ensures that its output is thrown away.

Remove this bit if you intend to receive the script's output by e-mail.

There is a chance that your job is running, but simply failing early (perhaps because the environment provided by cron lacks things provided by your testing environment); we will know once you get the cron e-mail after re-running this job.

9
  • i updated the cron script and gave the time 5 minutes ahead.do i need to add anything else where as well in some folder?
    – micheal
    Commented Mar 17, 2015 at 17:31
  • does it depend on time on which server runs?as i am giving my location time.
    – micheal
    Commented Mar 17, 2015 at 17:42
  • Yes, it should be server time. Run date to know what that is.
    – dhag
    Commented Mar 17, 2015 at 17:46
  • its showing UTC time.I made the time according to that time.but no luck
    – micheal
    Commented Mar 17, 2015 at 17:49
  • I would try running the script every minute with * * * * *, perhaps also redirecting its output to a file (>>/tmp/cron.log 2>&1 instead of what you had).
    – dhag
    Commented Mar 17, 2015 at 18:00

You must log in to answer this question.

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