Below is the LockFile part of my script. Lockfile should remove and recreate after 5 mins automatically as the script is set to run every 5mins to check to be sure the services on the server are running.
Lockfile is created but not removed after 5 mins.
#####################################################################################################
# will check if lock file exists, if not create it, or if lock file exists and
# is older than allowed time then delete lock file and try restart again.
#####################################################################################################
createLockFile(){
# check if the file exist already
if [ -f $LOCK_FILE_NAME ]
then
# see if older than 5 mins
if test "`find $LOCK_FILE_NAME -mmin +5`"
then
removeLockFile
else
# Lock file found, another instance of restart is running or lock file is less than allowed time.
exit 0;
fi
fi
touch $LOCK_FILE_NAME
} # End of createLockFile()
#####################################################################################################
## Descripton : will remove lock file, allowing future script runs.
#####################################################################################################
removeLockFile(){
A
echo "removing LockFile"
rm $LOCK_FILE_NAME
} # End of removeLockFile()