Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#this is the file you are going to
#see if it exists for a lock
lockfilename="/path/to/file/to/create/for/lock"
#file you are writing to
writefile="/path/to/writefile"
if [ -f $lockfilename ]
then
echo "File is in use"
else
touch $lockfilename
echo "informationtowritefile" >>$writefile
rm $lockfilename
fi
#!/bin/ksh
#===================
# Start of lock part
# Set the lock dir name (shared by processes so NO $$ in it !)
lockdir=/tmp/$(basename $0)-lockdir
# Set a trap to remove lock at script end (or abort)
trap "if test -d '$lockdir'; then
echo '$0($$): Releasing $lockdir';
rmdir '$lockdir';
fi" 0
while true; do
if mkdir "$lockdir" 2>/dev/null; then
# Ok we just created the lock dir so exit the waiting loop
echo "$0($$): Got lock '$lockdir': go on ..."
break
fi
# We failed to create the lock dir so wait and try again
echo "$0($$): Waiting for lock '$lockdir'"
sleep 1;
done
# End of lock part
#=================
# Here we have the lock
# Do our work
for i in 1 2 3 4 5; do
echo "$0($$): counting $i ..."
sleep 3;
done
echo "$0($$): Work done"
# Lock released by the trap "" 0 at start of script