I'm having some problems with a bit of script I'm using for making sure a script isn't running twice.
I've been using this for quite some time without much problems, but it is giving me trouble on a server I just upgraded from Ubuntu 15.04 to Ubuntu 15.10, so I think there might be something there.
The code I'm using looks like this:
# locking; make sure we are alone
lockfile-create /var/lock/mylockfile --retry 3 --quiet
result=$?
if [ ${result} -gt 0 ]
then
# allready running; bye!
exit 2
fi
lockfile-touch /var/lock/mylockfile &
lockfiletouch="$!"
trap "{ kill ${lockfiletouch}; lockfile-remove /var/lock/mylockfile; }" EXIT
However, this now results sometimes in the following error:
/usr/local/scripts/myscript.sh: line 1: 8173 Terminated lockfile-touch /var/lock/mylockfile
It happens less than 1% of the times the script is run, but it is run quite often.
Can anyone give me any clue on what might be causing this and how I can prevent this error?