Use a temporary lockfile containing the process id, e.g...
Code:
#!/usr/bin/ksh
LOCKFILE=/tmp/lockfile
#---At the start of your script check to see that a lockfile exists
if [[ -f $LOCKFILE ]]
then
#----If the lockfile does exist then check that the process is still running
# since it may have aborted and left the lockfile behind
if ps -p $(<$LOCKFILE) >/dev/null
then
echo job is still running
exit
fi
fi
#---Must be okay to run, so create the lockfile containing the process id
echo $$ > $LOCKFILE
#----Rest of script goes here
:
#----end
rm $LOCKFILE
Not tested.