Unattended Linux Wakeup, Backup, Shutdown (part 5)
The Master Plan, Cron Wakeups
At last we come to the end of this series and put all the pieces together, and put our fabulous unattended automatic backup scheme to work. You need never lift a finger except to run periodic checks to make sure everything is working correctly.
The first four parts:
Antec 300 Computer Case Quick Review
Arch Linux Backup Server-- Headless Administration
Linux Backup Server: Remote Wakeup, Automatic Shutdown
Linux Backup Server: Refining Rsync, Passwordless Authentication
The PlanHere's how it all fits together:
- Since I have a router that runs 24x7, that runs a cron job that wakes up the backup server. The wakeup command can be run from any computer on the same subnet as the server.
- Each client PC has its own backup script, also started by cron.
- Server and clients all have their own cron jobs to shut them off.
Cron WakeupThe wakeonlan command does not need root privileges, so you can run it with any unprivileged user. First verify what time your computer thinks it is with the date command. All the computers on your LAN should be synchronized with each other, which you can do with a local NTP server:
Tue Mar 1 13:58:21 PST 2011
OK, the time is right, so now create your crontab. This wakes up the backup server every night at 11:30 PM. Remember to use your own server's MAC address:
$ crontab -e
# m h dom mon dow command
30 23 * * * /usr/bin/wakeonlan -p 8 00:0H:34:15:CD:92
To save and close your new crontab, simply save and close your editor in the usual way. You'll see a confirmation like this if it is successful:
File Name to Write: /tmp/crontab.g38BLX/crontab
crontab: installing new crontab
cron uses your default editor, so if you don't like the default or don't have one, you'll have to set it according to whatever way your Linux distribution does it, which is a mess for another day.
m is minutes, 0-59
h is hour, 0-23
dom is day of month, 1-31
mon is month, 1-12
dow is day of week, 0- 6 Sunday through Saturday
command is the command or script you want to run
Asterisk means every day, month, or day of week.
The cron daemon supplies a default environment, defining HOME, LOGNAME, SHELL (=/usr/bin/sh), and PATH (=/usr/bin). If your command or script is not in your home directory or /usr/bin/, then you need to spell out the complete filepath. Commands in your home directory can use the HOME variable, like $HOME/commandname.
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader