LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2010, 03:05 PM   #1
yucklawyers
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
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.

?
 
Old 01-17-2010, 03:22 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
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.
 
Old 01-17-2010, 05:07 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by tronayne View Post
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.
 
Old 01-18-2010, 07:17 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
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...
 
Old 01-18-2010, 07:34 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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.

Last edited by evo2; 01-18-2010 at 07:35 AM. Reason: Typo
 
Old 01-18-2010, 07:40 AM   #6
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
Quote:
Originally Posted by yucklawyers View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I calculate minutes to the next 7:00am is, in a shell script ? Glenn D. Programming 3 11-20-2009 11:40 PM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
Automating the "killing" process via a shell script fatrandy13 Linux - Software 5 09-14-2007 12:59 AM
Shell-Script for killing processes oulevon Programming 4 02-14-2006 11:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration