The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cvs[commit aborted]:'root is not allowed to commit changes' rksubash UNIX for Advanced & Expert Users 1 05-22-2008 05:31 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 12:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 12:06 AM
Program received signal SIGABRT, Aborted. napapanbkk High Level Programming 1 06-06-2006 07:20 AM
BEGIN failed--compilation aborted abhijeetkul UNIX for Advanced & Expert Users 1 03-21-2006 12:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-21-2008
Registered User
 

Join Date: Nov 2006
Posts: 188
rerun a script if aborted and exited

Hello,

When I run a script, the script sometimes exited. I need to re-run it automatically again. Currently I am using crontab to run the script each 5 minutes. However, I need to have a better solution.

Any idea what to do?

thanks
Reply With Quote
Forum Sponsor
  #2  
Old 02-21-2008
Registered User
 

Join Date: Feb 2008
Posts: 91
quick Idea came on mind. could be better one. anyway you cna try this

call the script from another script and for value $?. if it failed, you can re-try 'n' times.
Reply With Quote
  #3  
Old 02-21-2008
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,263
If your script sets exit codes (as, in an ideal world, should any process) it is not too hard to use a script wrapper:

First your_script.sh skeleton:
Code:
#! /bin/ksh

.... your code ....

if [ ... some condition ...] ; then
     print - u2 "Houston, we have a problem. Aborting...."
     exit 1      # aborted for some reason
fi

... more of your code ....

exit 0      # normal exit
Now the wrapper.sh skeleton:

Code:
#! /bin/ksh

while : ; do
     your_script.sh         # call your_script.sh
     if [ $? -eq 0 ] ; then
          break         # exit the loop if your_script.sh finished normally
     fi
done

exit 0
I hope this helps.

bakunin
Reply With Quote
  #4  
Old 02-21-2008
Registered User
 

Join Date: May 2006
Posts: 101
hi melanie,

i guess your problem is that you want to make sure that your script is always running and you use the crontab to check if it does ?

As usual there is more that one way. If you need to be fast you can add this script to /etc/inittab very fast but if you are not root you can not do that.

Other wise the crontab is ok, check every minute (hour or what you need) if it is running.

pidof -x script >/dev/null || nohup script &
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0