Writing Ubuntu shell scripts
- by Lukesh
Write a script that will shut down one of your server called “appsserver” every night in order to preserve power. But before the appsserver is brought down, your script should do the following:
Check if there are any users logged into the appsserver
Check the size of the directory /usr/tmp is bigger than 1G and delete all its content.
If (a) is true, send a broadcast message to all user that the machine will shut down in 20 minutes and that they should log out of the appsserver
All the output of the commands in your script should be sent to a log file with the script running date appended to the log file itself (e.g. shutdown_14_Nov_2011.log).