I thought I'd worked out how to ensure only 1 instance of a shell script
was running (using grep and wc) but I now see that sometimes the script
name appears twice in the list of processes - any ideas?

eg (apols for wrapping) when running /home/michael/bin/backup-rsync-VERI
we get the below where it appears twice in the list of processes...

++ mktemp /tmp/chk_procs_XXX
+ TEMPFILE=/tmp/chk_procs_220
+ trap 'date|mail -s "$0 error" [EMAIL PROTECTED];echo Error
- aborting; exit' ERR
+ ps -elf
+ grep /home/michael/bin/backup-rsync-VERI
+ grep -v grep
+ tee /tmp/chk_procs_220
4 R michael  20219 20218  0  83   0 -  1020 -      18:18 ?
00:00:00 /bin/bash -x /home/michael/bin/backup-rsync-VERI
1 R michael  20223 20219  0  83   0 -  1020 -      18:18 ?
00:00:00 /bin/bash -x /home/michael/bin/backup-rsync-VERI
++ cat /tmp/chk_procs_220
++ wc -l
+ [[ 2 -gt 1 ]]
+ date
++ hostname -s
+ mail -s 'ratty /home/michael/bin/backup-rsync-VERI - already running'
[EMAIL PROTECTED]
+ rm /tmp/chk_procs_220
+ exit -1



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to