The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
generating data for 1 hour aajan Shell Programming and Scripting 0 03-17-2008 02:59 AM
help in hour grep ali560045 Shell Programming and Scripting 0 01-31-2008 12:03 AM
an hour less in 24 hour system bobo UNIX for Dummies Questions & Answers 3 10-23-2006 08:55 AM
find files older than 30mins,count and send mail kayarsenal Shell Programming and Scripting 4 09-27-2006 11:11 AM
1 Hour less bobo UNIX for Dummies Questions & Answers 6 05-16-2006 09:07 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-24-2008
Zak Zak is offline
Registered User
 

Join Date: Mar 2005
Posts: 31
Run a script on the hour but only for 30mins

Hi All,

I want to run a script on the hour during a 24 - hour period; easy enough cron will take care of that..however I want the script to only run for only 30mins..

so with the script it knows its 30mins are up so exits.

any ideas?

Any help, greatly appericated.


Thanking you all inadvance.
Reply With Quote
Forum Sponsor
  #2  
Old 04-24-2008
Registered User
 

Join Date: Jul 2007
Posts: 76
you can put the below lines as the first lines of your script..

#!/bin/sh
echo $$ > /tmp/myprog.lck
echo sleep 1800 > mytmp.sh
echo kill -9 \`cat /tmp/myprog.lck\` >> mytmp.sh
sh mytmp.sh &


while true; do echo ilan; sleep 2; done #here your script content goes instead of while loop
exit 0

this will terminate itself in 30 minutes...

-ilan
Reply With Quote
  #3  
Old 04-24-2008
Zak Zak is offline
Registered User
 

Join Date: Mar 2005
Posts: 31
You Sir are a genius !
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 12:10 PM.


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