cron step value

thufir hawat.thufir at gmail.com
Tue Aug 13 06:32:42 UTC 2013


from man 5 crontab:


Step values can be used in conjunction with ranges.  Following a range 
with ``/<number>'' specifies  skips  of  the number's value through the 
range.  For example, ``0-23/2'' can be used in the hours field to specify 
command execution every other hour (the alternative in the V7  standard 
is ``0,2,4,6,8,10,12,14,16,18,20,22'').  Steps are also permitted after 
an asterisk, so if you want to say ``every two hours'', just use ``*/2''.


As an example, I see:


root at dur:~# 
root at dur:~# cat /etc/cron.d/leafnode 
# Cron entries for Leafnode.
# Run /etc/news/leafnode/do-fetch-news every hour.
8 * * * *  news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/
news/leafnode/do-fetch-news; fi
root at dur:~# 
root at dur:~# 



now, every, let's say, two hours I want to run "killall fetchnews" 
because it has a tendency to stall.  Would that look like:


#cron to kill defunct fetchnews
* */2 * * * killall fetchnews


(leaving out the logic of looking for a zombie process (if that's correct 
terminology))


thanks,

Thufir





More information about the ubuntu-users mailing list