help required on scheduling

hi

I have a script, abc.sh
first time user will start a script using <<abc.sh start >>, inside a script using " at " i am schduling same script for every one hour. so my script always running .
total script execution time takes around 1sec
for closing same << abc.sh stop>>

here my problem is once it is started (schduled), if any other one staring again using <<abc.sh start >> in another terminal,then new instance has to report about old instance of script to user

how to do this

use a wrapper script, which can schedule the abc script, and then if required call that script.

May be like below:
Create an empty file when script is schedule by 'at' and check for this file existance when 1st argument is 'start'

if [ $1 = "start" ]; then
   if [ -f script_scheduled ]; then
      echo "Script is already running/scheduled"
      exit
   fi
fi
<Do other stuffs>
touch script_scheduled
<schedule using at>

Make sure to add code for removing file while stopping the script:

if [ $1 = "stop" ]; then
   rm -f script_scheduled
fi
1 Like