LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need method of killing shell script at 8:00am (https://www.linuxquestions.org/questions/linux-newbie-8/need-method-of-killing-shell-script-at-8-00am-782801/)

yucklawyers 01-17-2010 02:05 PM

Need method of killing shell script at 8:00am
 
Have a simple shell script which just runs rsync overnight. The script launches rsync, and loops until rsync returns zero or it's killed by ctrl-C.

Need a method to kill it at 8:00am every morning.

Centos 5.4, rsync v3.0.7.

?

tronayne 01-17-2010 02:22 PM

Well, at will do it one time, cron will do it every day.

Hint: you'll need the PID of the running script and you get that with ps -e, piping that into grep or fgrep with the name of the script then then into awk to print the PID subsequently used with kill.

colucix 01-17-2010 04:07 PM

Quote:

Originally Posted by tronayne (Post 3829991)
Hint: you'll need the PID of the running script and you get that with ps -e, piping that into grep or fgrep with the name of the script then then into awk to print the PID subsequently used with kill.

Or just use pkill. ;)

tronayne 01-18-2010 06:17 AM

Wow, pgrep and pkill; never heard of 'em before but they sure do look like a useful alternative.

Learn sumptin new every other day or so...

evo2 01-18-2010 06:34 AM

Could you post the script (a stripped down version)? If you are doing what I think you are doing, it will be easy for the script to exit itself just by checking the time in each loop iteration.

Cheers,

Evo2.

cola 01-18-2010 06:40 AM

Quote:

Originally Posted by yucklawyers (Post 3829972)
Have a simple shell script which just runs rsync overnight. The script launches rsync, and loops until rsync returns zero or it's killed by ctrl-C.

Need a method to kill it at 8:00am every morning.

Centos 5.4, rsync v3.0.7.

?

You can do some search with cron.


All times are GMT -5. The time now is 06:45 PM.