LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-25-2006, 11:10 PM   #1
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Rep: Reputation: 30
Kill process via name


Hi! I am looking for a script to kill a process based on name rather than process ID. The Process specifically is Backup Exec Remote Agent. I currently have a cron job set to start the process since it seems to lockup and we can't get our backups done daily. I wrote a simple script shown below.

#!/bin/bash
#cron job for backupexec

59 17 * * * /root/cronjobs/bkupexec.sh

#END

The problem is now that I do a ps -aux | grep -i agent I see several instances of the ./agent running.


[root@mail cron]# ps -aux | grep -i agent
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.5/FAQ
root 21583 0.0 0.1 1696 664 ? S Nov23 0:00 ./agent.be
root 21586 0.0 0.1 1824 832 ? SN Nov23 0:00 ./agent.be
root 2562 0.0 0.1 1700 664 ? S Nov24 0:00 ./agent.be
root 2564 0.0 0.1 1700 764 ? SN Nov24 0:00 ./agent.be
root 15968 0.0 0.1 1700 664 ? S 17:59 0:00 ./agent.be
root 15970 0.0 0.1 1700 700 ? SN 17:59 0:00 ./agent.be
root 17811 0.0 0.1 3768 676 pts/1 R+ 23:08 0:00 grep -i agent


How do I kill the old processes of ./agent before starting the agent again. Can I integrate something in the script that will kill via the name? Or does it specifically have to be a process ID and if so how do we know what process ID to kill since I assume they are unique?

Thanks

 
Old 11-25-2006, 11:25 PM   #2
budword
Member
 
Registered: Apr 2003
Location: Wisconsin
Distribution: Switched to regualr Ubuntu, because I don't like KDE4, at all. Looks like vista on crack.....
Posts: 675

Rep: Reputation: 31
Try this...

http://www.die.net/doc/linux/man/man1/killall.1.html
 
Old 11-25-2006, 11:37 PM   #3
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Original Poster
Rep: Reputation: 30
Thanks budword

I just appended killall ./agent.be to the script before the cron executes and it works perfectly.
I appreciate the fast response and help.

Thanks.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to kill process Jeon, Chang-Min Linux - General 6 08-09-2005 01:14 AM
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 03:32 PM
Cannot kill process Zeno McDohl Linux - General 13 04-14-2005 03:31 PM
kill a process bratch Linux - Software 9 04-13-2005 07:00 PM
How to kill a certain process? AMDPwred Linux - General 3 10-01-2002 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:54 PM.

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