How to stop the execution of .sh script at certain time?
I have the following script which ensure that a .php file will be invoked every 3 seconds.
#!/bin/bash
for (( i=0; i<43200; i++ ))
do
/usr/bin/php /var/www/vhosts/mydoma开发者_StackOverflowin.com/httpdocs/somefile.php
sleep 3
done
I would like to be able to stop the script excecution if the time is 23:58:59
Anyone can help me?
Thanks, Zoran
case `date +%H%M` in 2359) break ;; esac
Edit: I discovered the zero padding in the date formatting string was not portable, so I took it out. It's not useful or necessary in this case anyway.
AGAIN me.
since your script has no imput youmcan try to launch yor script in the following way:
./yourscript.sh & sleep 10 && kill %1 && fg
give it a try.
Se
I think there is no direct way without using a scripting language like python or perl.
here if yo want there is te perl script already implemented:
http://www.cyberciti.biz/faq/shell-scripting-run-command-under-alarmclock/
Utilization summary:
Create a file installTimeout.sh containing the following:
wget http://pilcrow.madison.wi.us/sw/doalarm-0.1.7.tgz
tar -zxvf doalarm-0.1.7.tg
cd doalarm-0.1.7
make
and run the command:
source installTimeout.sh
now it's transparent to you. When you want to give a timeout to your script yo just have to run:
doalarm 20 your script
Best, Ste
精彩评论