Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I ran this grep:

grep -r "\-\-\-foo\-\-\-" * | grep -vi bar

For the past 5 minutes my Mac has been running hot (I can hear the fan) and I can't hit Ctrlz or x or c to kill the current task.

Even the clock on my Mac hasn't updated in 6 minutes.

How can I kill the task?

share|improve this question
add comment

2 Answers

Ctrlz always works for me, to suspend the process and resume the shell terminal.

Then

kill -9 <PID>

or

pkill -9 bar

usually does the trick.

[p]kill -9 sends the KILL signal to the process identified by Process ID, or executable name.

On an Ubuntu box, you can substitute <PID> for `jobs -p`, (with backticks), which just prints the process ID of other child processes of the current shell (hopefully only the process just suspended with Ctrlz).

On OSX, you have to type in the PID manually, or use pkill. You can find other child jobs' PID's with jobs -l (jobs -p doesn't work on OSX), which prints other information as well as the PID.

In the case that Ctrlz doesn't work, open a new terminal window up and identify the process ID with

ps aux | grep bar

and [p]kill as above.

share|improve this answer
add comment

Open new Terminal, then type top in your Terminal. You'll see the list of process running, like in the following image

enter image description here

You can see the grep process id here. then press q. It'll come back to terminal again. Then kill the two process using, kill command:,

kill 4963
kill 4934
share|improve this answer
add comment

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.