2

How to stop a running cron job

Posted May 15th, 2011 in Razno and tagged , by Metod

That was the question I asked myself when a running cron job on a shared hosting went horribly wrong. Turns out the solution is ‘pretty’ easy. You just have to know when the cron job started. In my case it was a PHP script. So i grep-ed for php also.

  1. ps -ef | grep php

You get the list of processes matching your criteria. Then you have to look for the time the script should have started. In the second column there is it’s PID. You can use that to kill it.

  1. kill $PID

2 Responses so far.

  1. Nate says:

    This is really useful, thanks! What does the vertical line do, though? (the “|” before grep).

  2. Metod says:

    Glad it helped someone else. :)

    That “|” is called “pipe”. It is best described on wiki – http://en.wikipedia.org/wiki/Pipeline_%28Unix%29 :)