Writing Ubuntu shell scripts

Posted by Lukesh on Ask Ubuntu See other posts from Ask Ubuntu or by Lukesh
Published on 2011-11-13T17:12:57Z Indexed on 2011/11/13 18:06 UTC
Read the original article Hit count: 214

Filed under:

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:

  1. Check if there are any users logged into the appsserver
  2. Check the size of the directory /usr/tmp is bigger than 1G and delete all its content.
  3. 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
  4. 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).

© Ask Ubuntu or respective owner

Related posts about server