LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-10-2017, 05:23 AM   #1
Rotwang2
Member
 
Registered: Aug 2014
Distribution: Ubuntu, Centos, Fedora
Posts: 210

Rep: Reputation: Disabled
Kill a command line app?


How do I kill a (command line) app that's hanging?

Ok you're instinct is to say Ctrl-c. That's not working.

I'm running alpine, and it's stuck trying to send an email. So how do I kill it?

This is in runlevel 3, so there's no GUI here. I can't just open another terminal window; there are no windows.

I can't run top or ps to get it's id and kill it, because I don't have a command line besides this one, and it's stuck in alpine.

Ctrl-c isn't doing anything. What's left to do besides restart? I really don't want to restart and I doubt I need to but I don't know how to kill it if Ctrl-c isn't working.

It's an unusual situation, right. A conundrum.
 
Old 11-10-2017, 05:35 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Perhaps you should read up on using virtual terminals. Opening another may not help with the recalcitrant alpine though, depending on how it is "hung".
 
1 members found this post helpful.
Old 11-10-2017, 05:46 AM   #3
Rotwang2
Member
 
Registered: Aug 2014
Distribution: Ubuntu, Centos, Fedora
Posts: 210

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by syg00 View Post
Perhaps you should read up on using virtual terminals. Opening another may not help with the recalcitrant alpine though, depending on how it is "hung".
I love you! That was brilliant, I opened a new terminal, found the PID, and killed it. Brilliant, thanks syg00
 
Old 11-10-2017, 05:50 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
in general you can use Ctrl-Z to suspend the current job. Next execute bg to put that process into background and run kill <signal> %1 to kill it.

you can use pgrep and pkill also to find/kill a process.
 
1 members found this post helpful.
Old 11-10-2017, 05:58 AM   #5
Rotwang2
Member
 
Registered: Aug 2014
Distribution: Ubuntu, Centos, Fedora
Posts: 210

Original Poster
Rep: Reputation: Disabled
Talking

Quote:
Originally Posted by pan64 View Post
in general you can use Ctrl-Z to suspend the current job. Next execute bg to put that process into background and run kill <signal> %1 to kill it.

you can use pgrep and pkill also to find/kill a process.
Oh that's a good idea, I didn't think of trying Ctrl Z and then bg. I have a feeling it probably wouldn't have responded to Ctrl Z if it wasn't responding to Ctrl C.

And to get the pid, I did:

ps | grep "alp" from the other virtual terminal, and then just "kill <pid>". and then I switched back to the first one. woo! I love this stuff...

I didn't know about pgrep and pkill. I learned a lot here, if anyone else reads this thread, maybe this might be useful:

https://www.computerhope.com/unix/upgrep.htm

I forgot about HUP, and I also learned that nice has levels. That makes sense. I always just used nice with it's default settings.

Anyway thanks guys, long live linux.
 
Old 11-10-2017, 06:20 AM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Sometimes programs are so severely stuck that you have to force a kill. Then the program itself does not terminate, but the OS kicks it out of the execution queue.
Code:
kill -9 <pid>
Use it only when else is not possible. The terminated program does not release its resources. If you do it often you'll be out of resources sooner or later and must reboot.

In Linux we call applications programs or tasks. Not apps. That is for iShit and Windows.

jlinkels
 
Old 11-10-2017, 02:21 PM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
if ctrl-c doesn't do it, try ctrl-d.
and sometimes it just takes a while until the prompt returns.
 
1 members found this post helpful.
Old 11-10-2017, 05:12 PM   #8
watchingu
Member
 
Registered: Oct 2017
Location: USA
Distribution: Arch Linux, Debian Stable, Debian Unstable
Posts: 73

Rep: Reputation: 17
I use either gnome-system-monitor or as others have stated...
Code:
sudo kill -9 <pid>
 
Old 11-10-2017, 05:30 PM   #9
Rotwang2
Member
 
Registered: Aug 2014
Distribution: Ubuntu, Centos, Fedora
Posts: 210

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by watchingu View Post
I use either gnome-system-monitor or as others have stated...
Code:
sudo kill -9 <pid>
Right, but as I said, I didn't have a command line. I know how to use kill and ps | grep <name>

But I couldn't get to a command line. You see? (See original post.)

It was syg00's advice that got me to a command line, which is awesome and so relieving.

Last edited by Rotwang2; 11-10-2017 at 05:36 PM.
 
Old 11-10-2017, 11:58 PM   #10
watchingu
Member
 
Registered: Oct 2017
Location: USA
Distribution: Arch Linux, Debian Stable, Debian Unstable
Posts: 73

Rep: Reputation: 17
^ My apologies. I should have read your post more closely.
 
Old 11-11-2017, 03:49 PM   #11
Rotwang2
Member
 
Registered: Aug 2014
Distribution: Ubuntu, Centos, Fedora
Posts: 210

Original Poster
Rep: Reputation: Disabled
Hey I wanna also point out, (and I'm embarrassed to say this),

I realized that when I installed, (this is a fresh install), I had ticked the checkbox to include an ssh server. So I realized wait, I can just ssh in and that's just the same as another terminal window.

Just thought I'd mention that in case anyone else has the same problem,

rw

Last edited by Rotwang2; 11-11-2017 at 04:05 PM.
 
  


Reply



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
How to kill an idle user via the command line? goemon Linux - General 7 12-01-2005 06:01 PM
Please dont kill me for asking.. Command line? (I AM i n00b) Nox_hand Linux - Newbie 17 09-17-2005 03:59 PM
How can I see what process are running and how to I kill them? (command line). brynjarh Linux - Newbie 4 07-07-2004 03:01 PM
kill program command line demmylls Linux - General 7 02-09-2004 08:55 PM
one-line kill command using process name julianop Linux - Newbie 6 12-22-2003 11:33 PM

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

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