The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #1 (permalink)  
Old 01-03-2009
thepurple thepurple is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 134
which one is better Run by Cron or Shell

Dear Experts,

I have a script defined in Cron which runs every 1 minute.

Code:
* * * * * /export/home/myscript.sh >/dev/null 2>&1
Now the issue is executing that myscript.sh sometime will take 2/3 or more minutes to finish execution.

But after 1 minute cron will invoke another instance(process) execute the myscript. In that case do you think there is a probability to overlapping the instance and may create problem.


If there is a chance for overlapping may be the below shellscript(run it in background) is okay which will run every 1 minute. Script will invoke different instant after every minute.

Code:
#!/usr/bin/bash
while :
do
    sleep 60 & pid=$!
    /export/home/myscript.sh
    wait $pid
done
Could you please make your valuable suggestion?

//purple