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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
return previous line for pattern match braindrain UNIX for Dummies Questions & Answers 4 12-08-2008 05:17 PM
Return of EXIT status ( $? ) ZINGARO HP-UX 1 03-12-2008 07:07 AM
return the previous line user_prady Shell Programming and Scripting 12 12-18-2007 07:37 AM
return ftp status blt123 Shell Programming and Scripting 12 07-21-2005 05:48 AM
Return status... Shaz Shell Programming and Scripting 7 11-19-2002 06:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-26-2006
mpang_ mpang_ is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 89
Return status of all previous runs

hi, I set the crontab to execute script A every 5 minutes from 9:00 am to 4:00 pm everyday, now at 12:00am I want to run another script if and only if all the previous runs of script A return OK, can anyone tell me how it could be done? thank you very very much!
  #2 (permalink)  
Old 06-26-2006
x96riley3 x96riley3 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Nashville
Posts: 79
Set your script up to write to a tmp file a success or failure. Then take your new script and grep the file for failure. If failure exists then your cron script exits and notifies you. If no failure is found then you proceed and have that script notifiy you as well.

-X
  #3 (permalink)  
Old 06-26-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
You could split your cron line into three this way:
Code:
00,05,10,15,20,25,30,35,40,45,50,55 4-11,13-21 * * * script1.sh
00 12 * * * script1.sh && script2.sh
05,10,15,20,25,30,35,40,45,50,55 12 * * * script1.sh
At 12:00 script2.sh will only run if script1.sh finished with exit status of 0.
So you won't need a temp file.
Well, I think this should work, but I'm not sure
  #4 (permalink)  
Old 06-26-2006
mpang_ mpang_ is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 89
thank you guys, but could grial explains how your method works with a little more detail? I have pretty new with these stuff, thanks!
  #5 (permalink)  
Old 06-27-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Of course
Well, of the three crontab lines above, the second is the interesting one for you:
Code:
00 12 * * * script1.sh && script2.sh
You may consider it as a boolean expression, meaning that
script2.sh will run if, and only if, script1.sh finished successfully (exit 0).
This will happen at twelve o'clock.

The first line says that script1.sh will run from 4 to 11 and from 13 to 21 every 5 minutes. The last line says that script1.sh will run every 5 minues from 12.
Regards.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0