Saturday, November 4. 2006Host automatically up and down![]() For the usage of a local backup host, I defined the following scenario, which could also be used for a printer server or any other type of host, which shouldn’t run 24/7, but:
And here’s the shell-script which implements the above. It’s enough to have it run every five minutes. The “echoes” are only interesting for debugging purposes.
#!/bin/bash
lockfile=/etc/lock_shutdown upclient=fourier min_upminutes=30 # If shutdown locked, keep running if [ -f $lockfile ]; then echo “Locked” exit 0 fi # If client is still there, keep running if ping -t10 -c1 $upclient &>/dev/null; then echo “$upclient still there” exit 0 fi # If we are up long enough ... cur_secs=$(cut -d. -f1 /proc/uptime) if [ $cur_secs -lt $[$min_upminutes*60] ]; then echo “Not up long enough” exit 0 fi # ... then shut down! echo “Shutting down” /sbin/shutdown -h 1 &
Posted by Stephan Paukner
in GNU/Linux
at
18:05
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: bash, programming
Trackbacks
Trackback specific URI for this entry
|
AboutCalendar
ArchivesCategoriesShow tagged entriesandroid anti-spam apache astronomy austria automobile ballooning bash bluetooth bug career cloud collecting comic cooking crypto cw debian diy dreams education electronics event fail fashion finance flickr fuerteventura fun gentoo geography german gnu-linux google google earth guitar hardware history image processing internet kernel kids language lanzarote lhc lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus octave pdf perl philately philosophy phone photo gear photography podcast politics postfix private programming public transport rant religion review salzburg samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo
Syndicate This BlogFollow meBookmarks
Powered by |