Last active
August 29, 2015 14:01
-
-
Save lidio601/0a70fe53c730128c79f9 to your computer and use it in GitHub Desktop.
Linux bash script to auto switch off the computer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ris=`who | grep -c ""` | |
if [ "$ris" == "0" ]; then | |
echo "Non c'e' nessuno loggato! Spegno<br />`ps aux`" | mail -s "Spegnimento... " root | |
sleep 10s | |
/sbin/shutdown -h 10 | |
else | |
echo "C'e' ancora qualcuno loggato: `who -H`" | mail -s "Spegnimento... FAILED" root | |
/sbin/shutdown -c now | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment