Practical Web Programming

Saturday, December 09, 2017

Turn Off/On Ubuntu Server at Specified Time

If you are running a headless ubuntu server as a media server that is on 24/7, you could be wasting several hours of energy - especially at night when no one is using it. To solve this problem, you can automatically shut it down and turn it on at certain time using rtcwake. See below for step by step:
  1. Login as root and open `crontab`.
  2. $ sudo su
    $ crontab -e
  3. Add the command to crontab.
  4. # Shutdown at 12 AM and awake afer 8 hours (8:00 AM)
    0 0 * * * sudo /usr/sbin/rtcwake -m disk -s 28800 > /var/log/crontab.log

Recent Post