Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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".
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
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:
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
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.
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,
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.