Results 1 to 6 of 6
Hey Gang-
I'm wanting to write a script to run some commands and I wanted to do a for while loop that checks the current time to make sure it ...
- 06-21-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 5
Execute commands in bash/ksh between two times
Hey Gang-
I'm wanting to write a script to run some commands and I wanted to do a for while loop that checks the current time to make sure it falls between two static times.... lets say between 10:00 and 14:00.
Is there an easy way to do this? Or maybe it should be done outside the script?
Thanks!
- 06-21-2008 #2
If I get you correctly you want a script to run at a certain time ?
If so, you must use a crontab:
simply do crontab -e in your terminal
and add a line like this:
* * * * * /path/to/your/script
where the * respectively represent the: minute (0-59), hour(0-23), day of month(1-31), month(1-12), day of week(0-6) (where 0=sunday)
- 06-21-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 5
Well, yes and no. I want it to start at a specific time, but I also want to make sure it stops at a specific time. I want to make sure this script isn't running when the server is busy with other processes.
I just want to declare my start and stop times up front, but I'm not sure how to phrase the if then statement to check to see if the current time is between those two.
- 06-23-2008 #4Just Joined!
- Join Date
- Jun 2008
- Posts
- 5
Any help would be greatly appreciated. Thanks!!
- 07-02-2008 #5
You got just add two crontabs, one with the command to start your desired process at a given time and one with a command to kill your process at a given time.
- 07-02-2008 #6Just tell your script to be nice
Originally Posted by idiotboy 
Code:man nice
Can't tell an OS by it's GUI


Reply With Quote