[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem with init script.. :-[



In article <[🔎] 20020131071904.GA21828@mira.lan.galacticasoftware.com>,
Adam Majer  <adamm@galacticasoftware.com> wrote:
>How can I detect if the file(s) exist without causing
>the init script to bail out??

No need to use ls, you can use wildcards directly in the 'for':

  stop)
        echo -n "Stopping $DESC: "
        for i in /var/run/$NAME*.pid; do
                if [ -f "$i" ]; then
                        kill `cat "$i"` 2> /dev/null;
                        rm -f "$i";
                fi;
        done;
        echo "$NAME."
        ;;

If there is no pid file, /var/run/$NAME*.pid will not expand and
stay literally /var/run/$NAME*.pid. That means the '-f "$i"' test
will nicely fail, and the kill/rm is not done.

Mike.



Reply to: