Monday, 22 April 2013

lock process and allow the process to run after 1 mins

current=`date +"%s"`
last=`cat /tmp/last_date`
difference=`echo "$current - $last" | bc`
if [ ! -e /tmp/lock_file ] && [ $difference -gt 70 ]
then
touch /tmp/lock_file
sleep 10
echo "your command"
rm -rvf /tmp/lock_file
date +"%s" > /tmp/last_date
fi

No comments:

Post a Comment