Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I try to make runwhen perform a job every 6 hours, starting at 3:00 in the morning.

(How) Can this be done?

share|improve this question
1  
any reason not to just use cron? –  Kevin May 7 '12 at 1:45
    
there are some reasons (on this page in german: uberspace.de/dokuwiki/system:runwhen), they are: no collisions, execute time in settings, integrated logging, information when next execution takes place, do it now feature, temporary break. however finally I decided for cron :) –  Marcel May 10 '12 at 21:15
add comment

1 Answer

up vote 1 down vote accepted

found a solution - if somebody else is interested...

#!/bin/sh -e

RUNWHEN=",H/6"

# The constraint string consists of a sequence of unit constraints. Each unit
# constraint consists of a comma, one of the following letters indicating which
# unit is constrained:
#
#     * y: year.
#     * m: month (in the range 1-12).
#     * d: day of the month (in the range 1-28, 1-29, 1-30, or 1-31, as
#          appropriate for the month in question).
#     * w: day of the week (in the range 0-6, with 0 representing Sunday).
#     * H: hour of the day (in the range 0-23).
#     * M: minute of the hour (in the range 0-59).
#     * S: second of the minute (in the range 0-59). 
#
# and finally one of the following:
#
#     * =n: matches times when the given unit is exactly n.
#     * -n: matches times when the given unit is exactly m, where m+n is one
#           more than the largest value of the unit. (For example, n+m=24 for H,
#           so ,H-1 is equivalent to ,H=23.
#     * /n: matches times when the given unit is divisible by n. 

exec 2>&1 \
rw-add n d1S now1s \
rw-match \$now1s $RUNWHEN wake \
## here comes the interesting part
rw-add \$wake d3H wake \
sh -c '
  echo "@$wake" | tai64nlocal | sed "s/^/next run time: /"
  exec "$@"' arg0 \
rw-sleep \$wake \
thescript
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.