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
need help in IF condition!! raghav1982 Shell Programming and Scripting 18 02-09-2009 11:18 AM
if condition ... mahabunta Shell Programming and Scripting 4 02-14-2007 11:44 AM
awk and condition help gini Shell Programming and Scripting 5 12-13-2006 11:17 AM
if condition mahabunta UNIX for Dummies Questions & Answers 1 09-26-2006 10:47 AM

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

Join Date: Mar 2006
Location: Mumbai,India
Posts: 57
crontab condition

hi
i have one crontab file. In crontab file i want to write a if condition is it possible by any ways.

suppose on 22.00 .. i want to run test.sh file. but only when the flag in a outer file bust.txt is 1 otherwise dont execute. same.

can we use conditions in crontab file.?

Thank you.
Regards,
Swapneel
  #2 (permalink)  
Old 03-24-2006
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Hi Swapneel

At the chosen time. run a script which contains the if condition. it will have the desired effect and will also make the crontab file easier to read.

Cheers
Helen
  #3 (permalink)  
Old 03-24-2006
d_swapneel14 d_swapneel14 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Mumbai,India
Posts: 57
Hi helen

i got wht you r saying. See i have more than 100 of important scripts running on different time and date..... I need to modify each and every script to add this if condition/ clause.

instead of modifying all these files.. i m thinking to write a condition in crontab file. is it ok?or is it possible?can we write condition in cron tab file?


see unix is going to store all these scripts and there sheduled time. in any case is it possible to manage it in crontab file. see i cant update all of my calling scripts.

thanks a lot helen!

Best Regards,
Swapneel
  #4 (permalink)  
Old 03-24-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
0 22 * * * read a < bust.txt && [ $a -eq 1 ] && test.sh
  #5 (permalink)  
Old 03-24-2006
d_swapneel14 d_swapneel14 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Mumbai,India
Posts: 57
thanks a lot

Hi

Its working fine.
Thanks a lot Gunnies Mind.

Regards,
Swapneel
  #6 (permalink)  
Old 05-05-2006
blazingrock4u blazingrock4u is offline
Registered User
  
 

Join Date: May 2006
Posts: 2
Hi.. all
I have got 3 scripts: s1.sh, s2.sh, s3.sh
I want to run s1 at 15,30,45 mins of every hr.
s2.sh should run 10 mins after s1.sh has been executed.
s3.sh should run 10 mins after s2.sh has been executed.

Given the above case, wt approach shd be follwd. plz explain in detail (naive to Shell Prog)
  #7 (permalink)  
Old 05-05-2006
indo1144's Avatar
indo1144 indo1144 is offline
Registered User
  
 

Join Date: Jun 2002
Location: Netherlands
Posts: 54
Why not make the "trigger-condition" part of the script itself?

I don't know if a crontab is the right place for this. Of course it could be done, you can enter individual shellcommands in a crontab, so why not an if-then condition, but this makes things so much more complicated.
Keep all your logic in one place (script) and put the scheduling where it belongs (crontab).

Just my $0.02

Edit: Oops, didn't read the part where you have 100 scripts that you need to run. Why not use an overall-startscript that runs the other scripts? You can put your condition there...
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 07:31 AM.


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