For a long time I’ve known that
*/2 * * * * in crontab runs a job on every even minute (0, 2, 4, …, 56, 58). But today I needed to schedule a job to run every odd minute. My first thought was to schedule it with
*/2 * * * * and put a
sleep 1m in front of the command, but that seemed really hacky.
The more elegant solution is to use
1-59/2 * * * *, which I found on this post. After reading the
crontab(5) man page more closely, I found the answer there, too:
Ranges can include “steps”, so “1-9/2” is the same as “1,3,5,7,9”.