dotlockfile
Jay Nugent
jjn
Tue Jul 24 12:20:59 PDT 2007
Greetings,
On Tue, 24 Jul 2007, Michael Hipp wrote:
> Does anyone have a bash script that does essentially the same thing as
> the 'dotlockfile' utility?
>
> I have a system without dotlockfile but I need that functionality to
> keep a script from clobbering itself.
I just ran into this problem earlier today. So I'll be implementing
this lockfile code into my scripts tonight.
#
#==================================================================
# Test to see if we have a LOCK file (i.e. a copy is still running)
#
LCKFYLE="/home/wwnet/LCK-wwnet-dialusage"
#
if [ -f $LCKFYLE ]; then
/bin/mail -s "$LCKFYLE exists" jjn at nuge.com
exit 0
else
touch $LCKFYLE
#
#==================================================================
# We wrap the rest of the code from here on...
#
[ place the rest of your script in here ]
#
#==================================================================
#
# ... the end of the LCKFYLE test wrapper
#
rm $LCKFYLE
#
fi
#
#----------
#
# - end -
#
Hope that helps.
--- Jay Nugent
"Getting rid of terrorism is like getting rid of dandruff. It cannot
be done completely no matter how hard you try." -- Gore Vidal
+------------------------------------------------------------------------+
| Jay Nugent jjn at nuge.com (734)484-5105 (734)544-4326/Fax |
| Nugent Telecommunications [www.nuge.com] (734)649-0851/Cell |
| Internet Consulting/Linux SysAdmin/Engineering & Design/ISP Reseller |
| ISP Monitoring [www.ispmonitor.net] ISP & Modem Performance Monitoring |
| Web-Pegasus [www.webpegasus.com] Web Hosting/DNS Hosting/Shell Accts|
| LinuxNIC, Inc. [www.linuxnic.net] Registrar of the .linux TLD |
+------------------------------------------------------------------------+
3:01pm up 135 days, 11:28, 2 users, load average: 0.02, 0.06, 0.08
More information about the Linux-users
mailing list