I have a build machine for my work, but it takes a fair amount of power when running. So I have scheduled it to sleep by itself when it’s not my working hours. My hacked together root-crontab (sudo crontab -e
to edit) that I’ve been using successfully for almost a year looks like this:
# At 17:00 on every day-of-week from Monday through Thursday sleep for # 12 hours. 0 17 * * 1-4 (echo -n "Sleeping" && date && /usr/sbin/rtcwake -s 48600 -m mem && echo -n "Woke" && date) >> /home/matthew/cronlog 2>&1 # At 17:00 on Friday, sleep for 60 hours (Wake 7am Monday morning) 0 17 * * 5 (echo -n "Sleeping" && date && /usr/sbin/rtcwake -s 216000 -m mem && echo -n "Woke" && date) >> /home/matthew/cronlog 2>&1
It uses the rtcwake utility that can put the machine into a sleep mode for a period of time.