Good Afternoon,
I have switched from a Windows server to Ubuntu server and I have managed to replicate all the items I had on the old server with the exception of sleep mode.
I currently have Ubuntu Server 16.04.2 LTS installed and I simply cannot get it to wake using a crontab script.
using:
sudo rtcwake -u -s 120 - mem
makes the computer sleep for 2 minutes so I know the system is capable of sleeping and waking up, but trying transfer that to a script is difficult to me as it is all new and my knowledge of Ubuntu/Linux is very limited at the moment. so could you spare 2 minutes just to look over what I have done so far please.
The commands I have run so far are:
sudo crontab -e
then added this line at the end to test the feature out:
30 19 * * * /home/andy/suspend_until 19:45
In the suspend_until file is:
#!/bin/bash
# Auto suspend and wake-up script
# Argument check
if [ $# -lt 1 ]; then
echo "Usage: suspend_until HH:MM"
exit
fi
# Check whether specified time today or tomorrow
DESIRED=$((`date +%s -d "$1"`))
NOW=$((`date +%s`))
if [ $DESIRED -lt $NOW ]; then
DESIRED=$((`date +%s -d "$1"` + 24*60*60))
fi
# Kill rtcwake if already running
sudo killall rtcwake
# Set RTC wakeup time
# N.B. change "mem" for the suspend option
# find this by "man rtcwake"
sudo rtcwake -l -m mem -t $DESIRED &
# feedback
echo "Suspending..."
# give rtcwake some time to make its stuff
sleep 2
# then suspend
# N.B. dont usually require this bit
#sudo pm-suspend
# Any commands you want to launch after wakeup can be placed here
# Remember: sudo may have expired by now
# Wake up with monitor enabled N.B. change "on" for "off" if
# you want the monitor to be disabled on wake
xset dpms force on
# and a fresh console
clear
echo "Good morning!"
Credit to RedgeOnline
Then: chmod +x suspend_until
The server went into standby at 19:30 but never woke up.
Any help much appreciated
Thank you in advance for your time
Andy