Thomas Schmidt <[email protected]> (Do 08 Dez 2011 13:33:50 CET):
> Vielen Dank Heiko!
> 
> Ich habe folgendes Script geschrieben. Es funktioniert anscheinend
> ganz gut. Habe ich als Bash-Noob etwas Unsinniges gemacht?
> 
> Thomas
> 
> #########################################
> #!/sbin/sh
    /bin/sh oder falls Du „Bashismen“ verwendest, auch /bin/bash
> 
> # 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 &

Die zwei Zeilen oben könnte man auch so schreiben:

    if pgrep -f script1 >/dev/null
    then
        echo script1 already running
    else
        $DIR/script1 >> $DIR/logfile 2>&1 &
    fi

Bei den anderen dann analog.


> 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 )
Wozu hier die Klammer?

> do
> pkill -9 -f script1
> echo ".\c"
> sleep 1
> done && echo
Warum das &&?

-- 
Heiko

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Lug-dd maillist  -  [email protected]
https://ssl.schlittermann.de/mailman/listinfo/lug-dd

Antwort per Email an