Scenario: You have a user with no access to cron and need to schedule a job (say an rsync of a directory). The use of
at is not an option as you don't have a fixed end date.
While I bet there are thousands of ways to accomplish this here's mine:
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Quick and dirty:
Open a screen session and create a while loop like that:
while : ; do clear echo "$(date : Hey, I'm running this nice stuffz)" time do_stuff sleep 1d
The key here is the
sleep command: It accepts much more than just a value in miliseconds. There are format specifiers for second (s), minute(m), hour(h) and day(d). Even more, GNU sleep is not only able to handle integers as values but
it can actually handle arbitrary floats (
info '(coreutils) sleep invocation').
This means that you could write stuff like:
sleep 0.33d or sleep 0.5h
The latter is pretty much useless, but so you know ;)