|
|
#1 | ||
|
Junior Member
Join Date: May 2005
Posts: 8
|
Maintenance script
Hi
I hope I'm addressing the right forum. I wrote a little shell script the checks if the shoutcast process is up and running, if it is not it kills what there is (if any) and restart. I'm running it in cron every minute That is the restart script Quote:
Quote:
|
||
|
|
|
|
|
#2 |
|
Moderator
Join Date: Dec 2005
Location: Atlantic Beach
Posts: 7,998
|
hey, this is both more efficient and more informative than the scripts that I use. Beautifully simple too.
Cheers and thanks for sharing. I'll make sure I reference this to everyone who comes asking from now on! |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2005
Posts: 8
|
Radio-watchdog V1.4
--------------------- Code optimization and a little more This script is running under cron every one minute which makes sure your stream (as long as there is a source) will be down only for one minute at the most Here is the code: [PHP] #!/bin/bash ############################################################################## # This script was written by Yigal Dekel (yigald@gmail.com) and can be used # # freely as long as it is copied/used/implemented as it is. # # Radio watchdog 1.4 # ############################################################################## ############################################################################## # Creating General Variables # ############################################################################## active_dir=radio/current #file var will be used as a buffer wd_log="radio_watchdog.txt" web=$HOME/public_html/watchdog.log #End of user config #Starting to write to buffer file="$file\n" file="$file\n--------------------------------------------------------" file="$file\nCurrent date is `date |awk '{print $1,$2,$3,$4}' `" file="$file\n--------------------------------------------------------" file="$file\nServer uptime is `uptime |awk '{print $3,$4}' `" file="$file\n--------------------------------------------------------" ############################################################################## # Creating Variable for the watchdog script and writing it to a file # ############################################################################## wdpid=`ps -ef | grep -i radio_watchdog | grep -v grep | grep -v ps | awk '{print $1}' | uniq ` file="$file\n" rm $HOME/$active_dir/watchdog*pid echo $wdpid > $HOME/$active_dir/watchdog.$wdpid.pid file="$file\n" file="$file\npid of watchdog is $wdpid" touch $HOME/$active_dir/radio_watchdog.sh file="$file\n" ############################################################################## # checking if pid is exist for radio script # ############################################################################## radio_proc=`ps -x | grep -i screen | grep -v grep | awk '{print $1}' ` if [ -z "$radio_proc" ] then # $radio_proc is empty if [ ${radio_proc+EMPTY} = EMPTY ] then file="$file\nradio_proc is empty, but set" cat $HOME/$active_dir/sc_w3c.log2 > $HOME/$active_dir/sc Last edited by yigald; 21st April 2009 at 22:18. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|