Vielen Dank Heiko!
Ich habe folgendes Script geschrieben. Es funktioniert anscheinend ganz gut. Habe ich als Bash-Noob etwas Unsinniges gemacht?
Thomas
######################################### #!/sbin/sh
# Start & Stop Script # Thomas Schmidt 2011
DIR=`dirname $0`
case "$1" in start) echo Starting daemon... pgrep -f script1 > /dev/null && echo script1 already running. pgrep -f script1 > /dev/null || ./${DIR}/script1 >> ${DIR}/logfile 2>&1 & pgrep -f script2 > /dev/null && echo script2 already running. pgrep -f script2 > /dev/null || ./${DIR}/script2 >> ${DIR}/logfile 2>&1 & ;; stop) echo Shutting down daemon... pgrep -f script1 > /dev/null || echo script1 is NOT running. pgrep -f script1 > /dev/null && echo "stop script1...\c" while ( pgrep -f script1 > /dev/null ) do pkill -9 -f script1 echo ".\c" sleep 1 done && echo pgrep -f script2 > /dev/null || echo script2 is NOT running. pgrep -f script2 > /dev/null && echo "stop script2...\c" while ( pgrep -f script2 > /dev/null ) do pkill -9 -f script2 echo ".\c" sleep 1 done && echo ;; restart) # echo Restarting daemon... $0 stop sleep 1 $0 start ;; status) pgrep -f script1 > /dev/null || echo script1 is NOT running. pgrep -f script1 > /dev/null && echo script1 is running. pgrep -f script2 > /dev/null || echo script2 is NOT running. pgrep -f script2 > /dev/null && echo script2 is running. ;; *) echo "Usage: $0 { start | stop | restart | status }" exit 1 ;; esac
exit 0