Linked by Dedoimedo on Wed 8th Dec 2010 17:40 UTC
Linux Here's the latest in our new series on OS tips from power users: a seemingly trivial task. You have a computer, most likely a laptop, that you wish to keep suspended while you're not working. For example, let's say overnight. At the same time, you wish to run a handful of maintenance tasks, like backups and cleanup, which you don't normally do during the day. So you need a mechanism that will send your machine to sleep, wake it up when necessary, run cron jobs, then send it back to sleep again.
Permalink for comment 452991
To read all comments associated with this story, please click here.
A slightly better way
by james_parker on Thu 9th Dec 2010 20:16 UTC
Member since:

Why not combine the four cron jobs into one? Something like:

rdate -s server; hwclock --systohc; rtcwake args;

The script should start as soon as the system wakes up from rtcwake.

Or course, since this must run as root, full paths should be used; in addition, an additional rtcwake call will probably be needed to put the machine back to sleep until morning after completes.

This avoids any dependency on implicit timing, and keeps everything together in a logical unit.

Reply Score: 1