L
L
lazix2017-02-24 13:15:31
linux
lazix, 2017-02-24 13:15:31

How to make a job in cron that is NOT RUNNING at a certain interval?

Is it possible to formulate such task execution intervals in one line so that it runs once a minute all the time, except for the period from 5 to 5-15 in the morning?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-02-24
@lazix

# каждую минуту все часы, кроме 5
*     0-4,6-23 * * task

# с 15-й минуты в 5-й час
15-59 5        * * task

Or, in the command itself, check that the hour is not equal to 5 or the minutes are greater than or equal to 15:
if [ $(date +%H) -ne 5 ] || [ $(date +%M) -ge 15 ]; then echo "run run run"; fi;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question