* */6 * * * /path/to/command

I want this cron to run once in every 6 hour.

Whats wrong with the above cron definition, and why?

  • You don't even tell us whether that is the system crontab or a user crontab? – Hauke Laging Jun 1 '13 at 19:19
  • That'll run every single minute of every sixth hour, every day, every week, every month. – Shadur Jun 1 '13 at 21:12

You have to specify a minute value in the first column. The star there makes it run on each minute value.

10 */6 * * * /path/to/command

will make it run 10 minutes past the hour, every six hours (on all days).

From man 5 crontab: A field may be an asterisk (*), which always stands for 'first-last'. This implies all possible values.

  • will having * on the minute value make it to run, more than once. – chethu Jun 1 '13 at 19:10
  • Yes every minute – Anthon Jun 1 '13 at 19:11
  • Does that mean that the cron will run 6o times , on every 6th hour. – chethu Jun 1 '13 at 19:13
  • I expect your cron to do that yes. Because mine has a 10 in the first position, it will only run 10 past every 6 hours. – Anthon Jun 1 '13 at 19:17

It is not portable.

This one should always work:

0 0,6,12,18 * * * /path/to/command
  • @Anthon I did it as soon as I posted it but you definitely were faster to answer. You are likely right the main issue is there and not on the */6 portability. – jlliagre Jun 1 '13 at 19:13
  • @jillagre I did see a star there, now there is none, without your post showing an edit. So you must have corrected it while I commented. I will remove the comment. – Anthon Jun 1 '13 at 19:16

You can always use Cron job simulators to validate you Job run schedule.

Link for one of the cron job simulator - http://www.dataphyx.com/cronsandbox/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.