Bobo87
Bobo87

Reputation: 151

How can I set Crontab for a specific hour?

I'd like to set my Cron job to work at specific hour. Particularly, I'd like to set it at 1PM and 7PM every day of the year. How can I do? I wrote two line like those below:

0 13 * * * /usr/bin/php path/myphp.php
0 19 * * * /usr/bin/php path/myphp.php

but nothing works fine! Can someone help me?

Upvotes: 1

Views: 198

Answers (2)

shevron
shevron

Reputation: 3663

Keep in mind that there's a difference in format between a user's crontab (accessed with the command contab -e or what have you) and the system's crontab, managed in files like /etc/cron.d and others.

In a user's personal crontab, the format you used should work. In the system crontab, (if you place a new file or edit anything under /etc), make sure you specify the user name to run as before the command, for example:

0 13,19 * * * www-data /usr/bin/php path/myphp.php

Will run the command /usr/bin/php path/myphp.php as user www-data every day at 13:00 and 19:00.

Upvotes: 0

OneOfOne
OneOfOne

Reputation: 99205

0 13,19 * * * /usr/bin/php path/myphp.php should work, check your log / user mail for errors.

Upvotes: 1

Related Questions