1

I need to have a single cron tab entry configured for a scheduled job

The job runs at

0-4 hours and then 16-20 hours

I tried this

0 */0-4,9-23 * * * some_report.sh
*/15 0-4,9-23 * * * some_report.sh 

I checked this @ site http://cronchecker.net

but its not the correct entry..

How can i configure the cron expression for this job.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
oxygenan
  • 1,023
  • 2
  • 12
  • 21
  • Why can't you have two entries? – Leon Nov 04 '14 at 08:30
  • @Leon , Thats the last resort.. but cant we configure it with a single expression. I believe we should be able to – oxygenan Nov 04 '14 at 08:32
  • I can have it as below..but i dont feel thats the best way to do it.. * 1,2,3,4,16,17,18,19,20 * * * some_report.sh – oxygenan Nov 04 '14 at 08:36
  • Does the job run for 4 hours? trying to understand why you have 0-4 – Leon Nov 04 '14 at 08:44
  • @Leon : Basically it needs to run every 15 mts (*/15) for the first 4 hours of the day and then later part of the day, but here for the question i updated it as 0th minute. – oxygenan Nov 04 '14 at 08:54
  • You may want to check [Crontab command definitions](http://team.macnn.com/drafts/crontab_defs.html) which is shown in [How to create cron statement to run for multiple hours](http://stackoverflow.com/q/10811241/1983854). Basially, you cannot and you need to use the `1,2...` expression. – fedorqui Nov 04 '14 at 09:01
  • have you tried this cron, other than on cronchecker? because this tester gives a completely different result http://cron.schlitt.info/ – Leon Nov 04 '14 at 09:06
  • I don't understand what times you want your job to run, every 15 minutes in the time between 0-4 and 9-23? – baao Nov 04 '14 at 13:00

1 Answers1

1

0 0-4,16-20 * * * some_report.sh does exactly what you're asking.

Also try crontab.guru for similar crontab questions.