With #cron or #systemd timers, how can I run something every 2 minutes, except between 23:50 and 00:10?

I don't think there's a way to specify this, right? I can see having to write wrapper scripts to check the time and exit early.

#linux #unix #sysAdmin

@artfulrobot

Additively.

*/2 1-22 * * * #every 2 min from 0100 through 22:59

2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48 23 * * * # every 2 min from 2300-2348

12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 0 * * * # every 2 min from 0:12 through 0:58

@dashdsrdash
Your approach is good, but can be done more compactly:

*/2 1-22 * * * # 0100 to 22:59
10-59/2 0 * * * # 0010 to 0059
0-49/2 23 * * * # 2300 to 23:49

@artfulrobot

@momo @dashdsrdash
Yeah, that's a possibility. I think I'll stick with my workaround though to keep crontab simple to look at!

https://floss.social/@artfulrobot/116198665486856889