LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2004, 09:57 PM   #1
gsbarry
Member
 
Registered: Jan 2003
Posts: 42

Rep: Reputation: 15
Kill a process launched by a shell script


I have a script "A.sh". It will launch a automated SSH process.

However, sometimes, the SSH process get hanged.

I try to kill the script A.sh, but, the hanged SSH process is still alive.

I hope that if I kill the A.sh, the child SSH process can also be killed together?

(Maybe, getting the PID of the child SSH process, then kill it? I don't know how to write)
 
Old 01-05-2004, 12:22 AM   #2
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
Get the process ID using ps -u <username>

Then kill the process using kill -9 <process_id>
 
Old 01-05-2004, 02:16 AM   #3
gsbarry
Member
 
Registered: Jan 2003
Posts: 42

Original Poster
Rep: Reputation: 15
Thanks a lot
 
Old 01-05-2004, 11:56 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Or, the "faster" alternative,
skill
... or ...
fuser -k

Both will allow you various ways of killing
stuff, eg username, process name, ... saving
you looking up the PID.

E.g. skill -KILL nutscrape joe_blogg


Cheers,
Tink
 
Old 01-05-2004, 08:24 PM   #5
gsbarry
Member
 
Registered: Jan 2003
Posts: 42

Original Poster
Rep: Reputation: 15
skill is a quite powerful tool

But it needs me to give a signal name to it e.g. HUP, KILL.
I don't know what are they. Which website could teach me these things?
(I have try to search the google like "linux signals, HUP, KILL", but those pages are not talking about these things)

Thanks.
 
Old 01-05-2004, 09:31 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
But it needs me to give a signal name to it e.g. HUP, KILL.
I don't know what are they. Which website could teach me these things?
(I have try to search the google like "linux signals, HUP, KILL", but those pages are not talking about these things)
Just try a
man skill
in a terminal :)

It will give you all the details (well, almost) ...
and the ones it doesn't - it gives you other
references for ;) ... after 30 seconds of reading
(jump to end of man page, read SEE ALSO)
you'll come across
man 7 signal



Cheers,
Tink
 
Old 01-05-2004, 10:12 PM   #7
gsbarry
Member
 
Registered: Jan 2003
Posts: 42

Original Poster
Rep: Reputation: 15
Thanks, these documents is very useful
 
Old 01-06-2004, 02:09 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Pleasure mate, always glad to be helpful :}


Cheers,
Tink
 
  


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
why my script die itself when I try to kill a process?? jaimese Linux - Newbie 4 10-27-2005 05:50 AM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 05:39 AM
how do i kill a process from inside a bash script? mikaelo Programming 4 05-28-2004 08:51 AM
BASH script inform user and kill process mounters Programming 3 02-11-2002 04:57 PM
script at xwin start to kill old process(es) butthead Programming 3 02-01-2002 08:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:48 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
Open Source Consulting | Domain Registration