Darrin Chandler wrote:
Yes, but there might be a race condition while checking.
What I would like to do is to check if a shell script is already active. And
I don't want to use a lock file:
if [ $(pgrep -of "/bin/sh $0") -ne $MYPID ]; then
echo "I'm already active:" 1>&2
echo $(pgrep -olf "/bin/sh $0") 1>&2
exit 1
fi
If pgrep (with -o support) finds a process that is *older* than MYPID the
script is already active.
afaik that construction is faster than grepping ps, piping and comparing two
values but if there is a better solution I'm pleased to hear about. :)
--
No Swen today, my love has gone away
My mailbox stands for lorn, a symbol of the dawn
| Greg KH | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 006/196] Chinese: add translation of oops-tracing.txt |
| Luciano Rocha | usb hdd problems with 2.6.27.2 |
| Roland Dreier | Re: Integration of SCST in the mainstream Linux kernel |
git: | |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| David Miller | [GIT]: Networking |
| Natalie Protasevich | [BUG] New Kernel Bugs |
