[Ilugc] My deceptively simple shutdown script after music playsq

  • From: sivabsk2003@xxxxxxxxx (siva kumar)
  • Date: Fri May 21 16:23:54 2010

Good Script idea - Arun Khan

On Fri, May 21, 2010 at 3:28 PM, Arun Khan <knura9@xxxxxxxxx> wrote:

On Wed, May 19, 2010 at 7:47 PM, Parin Sharma <parin.sharma@xxxxxxxxx>
wrote:
On Wed, May 12, 2010 at 8:43 PM, Arun Khan <knura9@xxxxxxxxx> wrote:

Arun Sir, it would be nice if you can share that script  !! I have been
searching for such solution for a long time !!


Rather than give you the script it would be better if you write (you
should be able to do in one or two lines in the script) your own
script based on the usage of the following tools:

1. 'netstat -nt' to list all TCP connections without DNS resolution
2. 'egrep'  to filter out "ESTABLISHED" connection lines from above
3. use 'wc -l' to count the number of "ESTABLISHED" connection lines
from above step. and save it in a variable no_conns
4. invoke '/sbin/poweroff' if no. of $no_conns is -eq 0
5. Test the script and when you are satisfied that it works then
6. In /etc/cron.d/  create a file with crontab entries similar to what
may already be there in that directory.
7. Edit the min. field for frequency (interval in mins.) and hour
field for the time duration during which your script should be
executed.

Your "power off" script will run every 'x' min. interval during hours
a through b If you are setup is correct (script and cron entries).

Caveat:  it is assumed you log off from all your ssh/telnet sessions
and also remove any browser tab that refreshes it's respective page
every so often.

-- Arun Khan
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc




-- 
From,
B.Sivakumar
(?`?.???) Always
`?.?(?`?.???) Keep Smiling
(?`?.???)?.?? N Be Happy!!
`?.?.??

Other related posts: