how to create a pid?

OP
OP
W

wonslung

Aspiring Daemon

Reaction score: 17
Messages: 850

SirDice said:
Having thought about this a bit, you can probably get away with a really simple cron entry.

Cronning something like pgrep myprogram || /usr/local/bin/myprogram might just be enough.

Pgrep returns 0 when 1 or more processes are found, if that's the case the other part of the logic OR is executed. When pgrep returns 1 (when no processes are found) execution stops (the other part of the OR is not executed).
that is similar to what i did, hold on, i'll show you what i did
Code:
#!/bin/sh
SERICE=

if pgrep -u $USER $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is fine"
else
    echo "$SERVICE is not running"
fi
i add the service name i want to check for, and add a command under the else and it works perfectly. It checks if it is running for each user because of pgrep -u $USER
i'm really new to this sort of stuff but if people push me in the right direction i can do it =)
 
Top