Home » Nodejs » How to stop Grunt

How to stop Grunt

Posted by: admin November 29, 2017 Leave a comment


This question may be obvious to some, but I searched all over the internet and couldn’t find the answer. I was following an install guide on Strut. How do I stop the Grunt task? I’m running Windows 7.

  • If it’s a task that you currently running you can stop it with ctrl + c

  • If it’s a task that is running in background you can find his process id (pid) with ps aux | grep grunt and then kill it with kill {pid}


One liner to kill the currently running grunt task:

kill -9 $(ps -aux | grep -v "grep" | grep grunt | awk '{print $2}')


Kill is the command to end a process

The -9 option is used to ensure the process is actually killed if it’s stuck in a loop

ps -aux lists the currently running processes

grep -v “grep” excludes any lines with the word grep so we don’t kill the current grep command that we are running

grep grunt just returns the line with grunt

And finally awk ‘{print $2}’ returns the number in the second column that is the pid. This is what is passed to kill.


A shorter solution with a nifty trick like Felix Eve’s:

kill -9 $(ps -aux | grep "[g]runt" | awk '{print $2}')

The [] avoids having the word ‘grunt’ in the grep, so it won’t get accidentally deleted.