The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-03-2009
thepurple thepurple is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 134
Quote:
Originally Posted by Panos1962 View Post
Code:
...
lock=/export/home/.myscript.lock
trap "rmdir ${lock}; exit 2" 1 2 3 15
# Now lock. If lock fails, then propably the program is runing.
mkdir ${lock} || exit 0
...
Here comes the script code
...
# Now unlock, so another instance of this program can run in the future.
rmdir ${lock}
is it just like..


Code:
#!/usr/bin/bash
lock=/export/home/.myscript.sh.lock
trap "rmdir ${lock}; exit 2" 1 2 3 15

mkdir ${lock} || exit 0
...
Here comes my script code
...
rmdir ${lock}


After that i can put the script in Crontab.

In that case every 1 minute cron will invoke process and child process. But meanwhile, the program (myscript) can be running with different process and child process id.

right?

//purple