faqts : Computers : Programming : Languages : PHP : Function Libraries : System

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 59 people (39%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I read all unix processes from PHP?
Can I kill unix processes from PHP?
How can I insert a sudo command in a php script? I inserted it as $fun="sudo less ~home/guest/aa.txt

Jan 12th, 2000 05:20
Nathan Wallace, Ajantha Wijeratna, Fredrik Rovik


You can return a list of processes with the unix command:

    ps

You can probably pipe it trough awk to return only the important
processes.

    <?
    $fp=popen("/bin/ps -aux","r");
    while (!feof($fp)) {
      $buffer = fgets($fp, 4096);
      echo nl2br($buffer);
    }
    ?>

To kill processes you will need to run a command as root or the owner of
the process.  You might be able to do this using sudo or similar.