Skip to main content
added 128 characters in body; added 62 characters in body
Source Link
waltinator
  • 6.9k
  • 1
  • 25
  • 27

In your script:

# store the Process ID here
pidfile=/var/run/mypid.local
# If there's a stored PID, terminate with SIGKILL
[[ -f $pidfile ]] && kill -s 9 $(cat $pidfile)
# Save our PID for the next run to kill
echo "$$" >$pidfile
  

and, to clean up, just before you exit,

rm $pidfile

In your script:

pidfile=/var/run/mypid.local  
[[ -f $pidfile ]] && kill -s 9 $(cat $pidfile)
echo "$$" >$pidfile
  

In your script:

# store the Process ID here
pidfile=/var/run/mypid.local
# If there's a stored PID, terminate with SIGKILL
[[ -f $pidfile ]] && kill -s 9 $(cat $pidfile)
# Save our PID for the next run to kill
echo "$$" >$pidfile
  

and, to clean up, just before you exit,

rm $pidfile
Source Link
waltinator
  • 6.9k
  • 1
  • 25
  • 27

In your script:

pidfile=/var/run/mypid.local  
[[ -f $pidfile ]] && kill -s 9 $(cat $pidfile)
echo "$$" >$pidfile