P.S.: that's the autosuspend script I'm using
#!/bin/bash
# Source the configuration file
. /etc/autosuspend.conf
# Log system notice
logit()
{
logger -p local0.notice -s -- AutoSuspend: $*
return 0
}
# Look for other CLIENTS in the network
IsOnline()
{
for i in $*; do
ping $i -c1
if [ "$?" == "0" ]; then
logit "CLIENT $i is still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsRunning()
{
for i in $*; do
if [[ `pgrep -c $i` > 0 ]] ; then
logit "PROCESS $i still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsDaemonActive()
{
for i in $*; do
if [[ `pgrep -c $i` > 1 ]] ; then
logit "DAEMON $i still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsBusy()
{
# Samba
if [ "$SAMBANETWORK" ]; then
if [ `/usr/bin/smbstatus | grep $SAMBANETWORK | wc -l ` != "0" ]; then
logit "SAMBA connected, auto suspend terminated"
return 1
fi
fi
#daemons that always have one process running
IsDaemonActive $DAEMONS
if [ "$?" == "1" ]; then
return 1
fi
#backuppc, wget, wsus, ....
IsRunning $APPLICATIONS
if [ "$?" == "1" ]; then
return 1
fi
# No Suspend if there are any users logged in
if [[ `who | wc -l` > 0 ]];then
logit "USERS still connected, auto suspend terminated";
return 1
fi
IsOnline $CLIENTS
if [ "$?" == "1" ]; then
return 1
fi
return 0
}
IDLE_FILE="/var/spool/autosuspend_idle_marker"
OFFFILE="/var/spool/autosuspend_off"
# turns off the auto suspend
if [ -e $OFFFILE ]; then
logit "auto suspend is turned off by existents of $OFFFILE"
exit 0
fi
if [ "$AUTO_SUSPEND" = "no" ]; then
logit "auto suspend is turned off in configuration file /etc/autosuspend.conf"
elif [ "$AUTO_SUSPEND" = "yes" ]; then
# Check if system is busy now.
IsBusy
if [ "$?" == "0" ]; then
# Idle now. Has the system been idle on the previous check?
if [ -e $IDLE_FILE ]; then
# Suspend now.
logit "AUTO SUSPEND CAUSED"
rm -f $IDLE_FILE
systemctl suspend
exit 0
else
# Mark system as idle for the next check.
touch $IDLE_FILE
logit "marked as idle for next check"
exit 0
fi
else
# Busy now. Mark system as busy for the next check.
rm -f $IDLE_FILE
logit "marked as busy for the next check"
exit 0
fi
exit 0
else
logit "misconfiguration. Check /etc/autosuspend.conf"
fi
exit 1