Hello everyone,
I am having some difficulty finding the right information. I have a server that is only needed at certain times. Wake-on-lan works well, so I can do administration, etc.
rtcwake works, so I can tell it to wake each day 3-5 minutes or so (haven't decided) before when it is needed.
The problem I am having is figuring out how to set it up so it automatically goes to sleep after X period of time and stay asleep.
This is a F20 system, so systemd is installed. I would like to have a script get called prior to sleep so it can set rtcwake.
I cannot find any documentation for a non-X/gui/gnome/whatever system to set up the idle time out. Do the hooks in /etc/pm/sleep.d work with systemd?
I prefer to do suspend to ram for this setup.
Thank you for any help, Trever
On 19.5.2014 12:15, Trever L. Adams wrote:
The problem I am having is figuring out how to set it up so it automatically goes to sleep after X period of time and stay asleep.
Hi Trever.
I played with systemd a bit and made a script you can be inspired with (I hope).
Create a script /usr/lib/systemd/system-sleep/autosleep.sh and make it runnable: ----------------------------------------------------- #!/bin/bash
# See: http://www.freedesktop.org/software/systemd/man/systemd-hibernate.service.ht...
PHASE="$1" TYPE="$2" sleep 30
echo "$(/bin/date +%Y%m%d-%H%M%S) P=$PHASE, T=$TYPE"
/var/log/autosleep.log
if [ "$PHASE" == "post" -a -f /autosleep ] ; then RUNTIME= . /autosleep if [ "$RUNTIME" -gt 0 ] ; then case "$TYPE" in suspend|hibernate|hybrid-sleep) echo '/sbin/pm-suspend-hybrid' | at now + $RUNTIME minutes echo "$(/bin/date +%Y%m%d-%H%M%S) autosleep in $RUNTIME minutes"
/var/log/autosleep.log
;; *) ;; esac fi fi ----------------------------------------------------- Then create a control file /autosleep: ----------------------------------------------------- RUNTIME=10 ----------------------------------------------------- Replace number 10 with value you like, time is in minutes.
To start autosleep just sleep system manually. Next sleeps occurs automatically. To stop autosleep first delete scheduled task by /bin/at -d and then remove /autosleep file.
It seems hooks in /etc/pm/sleep.d doesn't work with systemd.
On 05/27/2014 02:54 PM, V.99 wrote:
On 19.5.2014 12:15, Trever L. Adams wrote:
The problem I am having is figuring out how to set it up so it automatically goes to sleep after X period of time and stay asleep.
Hi Trever.
I played with systemd a bit and made a script you can be inspired with (I hope).
Create a script /usr/lib/systemd/system-sleep/autosleep.sh and make it runnable:
#!/bin/bash
# See: http://www.freedesktop.org/software/systemd/man/systemd-hibernate.service.ht...
PHASE="$1" TYPE="$2" sleep 30
echo "$(/bin/date +%Y%m%d-%H%M%S) P=$PHASE, T=$TYPE"
/var/log/autosleep.log
if [ "$PHASE" == "post" -a -f /autosleep ] ; then RUNTIME= . /autosleep if [ "$RUNTIME" -gt 0 ] ; then case "$TYPE" in suspend|hibernate|hybrid-sleep) echo '/sbin/pm-suspend-hybrid' | at now + $RUNTIME minutes echo "$(/bin/date +%Y%m%d-%H%M%S) autosleep in $RUNTIME minutes" >>/var/log/autosleep.log ;; *) ;; esac fi fi
Then create a control file /autosleep:
RUNTIME=10
Replace number 10 with value you like, time is in minutes.
To start autosleep just sleep system manually. Next sleeps occurs automatically. To stop autosleep first delete scheduled task by /bin/at -d and then remove /autosleep file.
It seems hooks in /etc/pm/sleep.d doesn't work with systemd.
Thank you. I believe I can make work with this for making mine systemd, right now it is cron. I use rtcwake instead of sleep. As I need it to wake up for specific timed events (backups, that is what the machine does). I also have it set to wake-on-lan so that I can do restores if needed.
The problem I need to figure out is how to have it sleep when the system is idle. I have others that this would work well for, if I could do that. Gnome, etc. does this. I haven't found a command line/systemd setup that will do this.
Say 10 minutes of being idle.
Thank you for your help!
Again, I now see clearly some systemd things I didn't before.
Trever