Dennis Davis wrote:
On Tue, 6 Mar 2007, Dennis Peterson wrote:
From: Dennis Peterson <[EMAIL PROTECTED]>
To: ClamAV users ML <clamav-users@lists.clamav.net>
Date: Tue, 06 Mar 2007 11:18:30 -0800
Subject: Re: [Clamav-users] msrbl sigs: rsync
Reply-To: ClamAV users ML <clamav-users@lists.clamav.net>
...
if [ -f "$RunFlag" ]; then
echo "This script already running. Cleaning up..."
/usr/bin/rm $RunFlag
/usr/bin/pkill sanesecurity.sh
else
/usr/bin/touch $RunFlag
fi
...
This is getting a bit off-topic, but here goes anyway...
I believe there are potential race problems in the above method
of locking. Not necessarily in this case where the script is run
infrequently. But in general when you've no idea when a particular
script may run.
It is very simplistic but the application allows it and cron is very
much involved. This would not work if cron were capable of creating
overlapping instances. The intention was to prevent blocking by a broken
process and there's lots of room for more elegance. For example, this
assassin script of mine won't run again until cron fires it off hours
later. Better would be to kill off previous instances and then attempt
to complete the mission. That is best done with serialized pid filenames
so the new instance doesn't have to kill itself as well as it's
predecessors.
Your alternative on first glance seems to give up without destroying the
previous instance, so it will never allow the rest of the script to run
to completion. That is safe from a process table view but doesn't help
refresh the databases.
dp
_______________________________________________
Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net
http://lurker.clamav.net/list/clamav-users.html