[NTLUG:Discuss] Flock file hanging around
Neil Aggarwal
neil at JAMMConsulting.com
Mon Jan 28 17:21:28 CST 2013
Stuart:
Thank you for your help on this.
I am trying to modify the script to notify root if the processes in my
script are still executing after an hour, so I modified my script to this:
#!/bin/bash
LOCKFILE=/var/lock/mylock.lck
(
if [ flock -n -s 200 ]; then
# Execute commands
...
sleep 5
else
if [ $(( $(date +%s) - $(date +%s -r $LOCKFILE) )) -gt 3600 ]; then
sendmail root "Lock file more than 1 hour old";
fi
fi
) 200>$LOCKFILE
I am getting this error on the if statement around the flock command:
[: too many arguments
I am not sure why it is complaining since the flock command is supposed to
return a value when called with the -n argument.
Any ideas?
Is there a better way to do this?
Thanks,
Neil
--
Neil Aggarwal, (972)834-1565, http://UnmeteredVPS.net/centos
Virtual private server with CentOS 6 preinstalled
Unmetered bandwidth = no overage charges
More information about the Discuss
mailing list