RE: Killing a process with php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hey chris...

can you tell us what you're trying to accomplish, and what the processes
you're looking to kill are doing? why are you trying to kill them on a daily
basis.. i'm assuming that you don't want hanging socket processes just
sitting on your system...

-bruce


-----Original Message-----
From: Richard Lynch [mailto:ceo@xxxxxxxxx]
Sent: Wednesday, May 09, 2007 11:30 AM
To: chris@xxxxxxxxxxxx
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Killing a process with php




On Tue, May 8, 2007 8:26 pm, chris@xxxxxxxxxxxx wrote:
> Hi could someone give me examples on how to detect and kill processes
> on
> linux.
> I have a number of scripts running as socketxxx.php these stop and
> start
> every hour.
> But I also need to at the end of each day make sure their dead before
> the
> next days start.
>
> These processes are also running as root user.

su to root

ps auxwww | grep socketxxx.php

If 'xxx' changes, you could just maybe do:

ps auxwwww | grep socket | grep php

Once you're sure you know what you want to kill, you could use 'kill'
to kill it.

You'll need the process ID number, which is the first number you see
in the row, right after the username.

Now that I've answered your question...


Almost for sure, whatever it is you THINK you should be doing, you've
done something else horribly wrong that is making you THINK you should
be searching for and killing these processes, but you shouldn't.  :-)

Since they already ARE php, it would probably be MUCH simpler to alter
the PHP in your socketxxx.php script, and add a couple lines like
this:

<?php
  $start = date('Y-m-d');
  //more code here
  while (1){
    if (date('Y-m-d') != $start) exit;
    //socket reading/handling code here
  }
?>

This presumes you actually need the process to die in the first place,
which sounds kinda hinky in and of itself, to tell you the truth...

Most Un*x socket-based processes start at boot and run forever until
the machine is shutdown, or somebody trips over the power-cord.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux