Hi I have a shell script I would like to run it has to run twice a day every 5 seconds for an hour I can do this with cron but I was hoping there was an easier way. Is there a way to make a process sleep only at a certain time of day say between 1 and 2 pm? Or under certain conditions?
Any help you can give me with this would be greatly appreciated
I don't know why you don't like cron
try man at
example :
echo "/usr/bin/ksh /path/to/script/scriptname.ksh" | at 10:30
at 1030 <<< "/usr/bin/ksh /path/to/script/scriptname.ksh"
Since you want it to run every 5 seconds... for an hour, scheduled twice a day I dont see anything simpler than using cron twice a day, since cron cannot deal with seconds, that part must be done using sleep...
Hi thanks for taking time read my post. Hmm can I set a process to stop with cron? I knew that I could set it to start but if the process continues to run for more than an hour it will cause problems.
Thank you
I think you can keep track of pid of your command
example :
$ your_command
$ echo $! >/path/to/pid.file
after some duration you can easily kill it.
Thanks again, I am not really all that familiar with shell programing, but I try to muddle through. Could I set another cron processs an hour latter to stop the running command with out having to find the pid first? can I do it by name only?
Thanks again
Well you could use a loop and a counter : 1 hour every 5 sec, thats 720 executions...
exit once value is reached...
If you have it on your OS, also check the watch
command
man watch
No unfortunately I do not have the watch command.
---------- Post updated at 10:25 AM ---------- Previous update was at 10:05 AM ----------
Thanks, you that sounds like what I need I will try that