Find the answer to your Linux question:
Results 1 to 2 of 2
Hello A friend of mine runs a Debian host and uses CRON to start a PHP script regularly to download the weather for his location, but sometimes, the script goes ...
  1. #1
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127

    Question Greping ps to kill rogue process?

    Hello

    A friend of mine runs a Debian host and uses CRON to start a PHP script regularly to download the weather for his location, but sometimes, the script goes haywire, so he'd like to run a CRON job to grep through ps, and kill this program if it's been running for eg. 20mn.

    I know that the real solution is to find out why the PHP script goes crazy in the first place, but he needs this ASAP.

    Anybody knows what SH/BASH commands to include in a script to do this?

    Thank you.

  2. #2
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127
    I think I found it:

    killall -9 myscript.phpcli

    Otherwise, there this:

    kill -9 `ps ax | grep myscript.phpcli | grep -v grep | awk '{print $1}'`

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...