Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For ex - if I enter ping one.com the process will keep running - if I want to stop that process, I can type Ctrl C which if I'm not mistaken, will kill the process completely. If instead, I stop it with Ctrl Z, isn't it true that the process can still be operating in the background at some level? How is one able to spot a condition where a process is running but can't be seen on the terminal screen? Thanks.

share|improve this question
4  
"I stop it with Ctrl Z, isn't it true that the process can still be operating in the background" — Not usually, no. The process can intercept the signal and perform shenanigans to make itself continue to run, but in general and by default, suspended means suspended, and after Ctrl-Z the process is suspended and not running. – Celada Feb 26 at 22:24
2  
Run the jobs command to see what jobs are in background or suspended – Stéphane Chazelas Feb 26 at 22:29
    
Yes - this seems to be the place to start, will remember - thanks . – bensatlantic Feb 27 at 15:44
up vote 6 down vote accepted

Use the jobs built-in to see running tasks for your current shell.

$ ping google.com >/dev/null 2>&1 &
[1] 32406

$ jobs
[1]+  Running                 ping google.com > /dev/null 2>&1 &

$ ping google.com
[...]
^Z
[2]+  Stopped                 ping google.com

$ jobs
[1]-  Running                 ping google.com > /dev/null 2>&1 &
[2]+  Stopped                 ping google.com

To kill all running jobs, you can leverage jobs -p which lists the pids of all jobs.

$ for job in $(jobs -p); do kill $job; wait $job; done

Further reading: http://www.tldp.org/LDP/abs/html/x9644.html

share|improve this answer
    
In the referenced TLDP.com page, especially see "fg" and "bg". – TOOGAM Feb 27 at 7:11
    
Very helpful - this is what I was looking for - thanks. – bensatlantic Feb 27 at 20:49

run ps -aux | grep "processname" to see if process running

run kill "processID" to kill specified process, PID is second set of numbers in previous command in line with target process

run killall "processname" to kill all processes with defined name

share|improve this answer
    
You can usually also pgrep "process name" to get a list of PIDs matching that name – DopeGhoti Feb 26 at 22:33
    
This is very helpful - I can now spot the ID of the processes and am tuned in to that. Thanks. – bensatlantic Feb 27 at 20:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.