user8160918
user8160918

Reputation:

How to make crontab execute every 2 hours between 10am and 10pm?

I need my crontab to execute every 2 hours starting at 10am and the last one running at 10pm.

I currently have

0 */2 * * * /directory/job.sh

How do I block out the hours I don't want?

Thanks!

Upvotes: 21

Views: 32386

Answers (1)

Christian Pekeler
Christian Pekeler

Reputation: 1070

0 10/2 * * * /directory/job.sh would do it.

0 10-22/2 * * * /directory/job.sh would do it and be more explicit.

0 10,12,14,16,18,20,22 * * * /directory/job.sh would do it, too.

Upvotes: 41

Related Questions