Link to home
Start Free TrialLog in
Avatar of benpung
benpung

asked on

make unix sleep?

here's the thing.  i'm running hp unix ksh shell.  i have a shell script that i want to execute every 5 minutes starting at 2am and ending at 5 am. the shell script will log into a database running on the same server, check a table for the presence of a flag, and depending on the flag, do something or do nothing. my question is, is there a way to make unix run a shell scipt every 5 minutes without making a ton of entries in a cronfile and using crontab? please help!
Avatar of shivsa
shivsa
Flag of United States of America image

use sleep 300
it will make script to sleep for 5 minutes.
u can use a while loop
while :  # this will make your script to run forvere
do
 check something
 do something or nothing.
 sleep 300
done
Avatar of HamdyHassan
HamdyHassan

You still need crontab because "starting at 2am and ending at 5 am"

$ crontab -e
# My Script do that, and run Mon-Fri 2:00AM - 5:00AM - Every 5 min
0,5,10,15,20,25,30,35,40,45,50,55 2-5 * * 1-5 /home/script_path/script.ksh

ASKER CERTIFIED SOLUTION
Avatar of HamdyHassan
HamdyHassan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial