views:

393

answers:

3

Can a normal member (not an admin) of a shared webserver with (limited) SSH access run, monitor and stop a PHP script through SSH? If so, how would all three actions be done by the user?


I tried to use the command "top", but it only listed actual top level processes, not PHP scripts. I have also managed to start a PHP script using the commands provided in this SO question. But what about termination and monitoring of the currently running PHP scripts?

+2  A: 

AFAIK you can not as the script runs under different user than the one you can log into via SSH.

dusoft
Is it not possible to run the script under the same user as the SSH session?
Tom
+1  A: 

If you are running the php script from the console like so:

php myscript.php

Then you should be able to kill the process:

killall php

You should probably use top to find the pid and then use kill in place of killall

MitMaro
Quote: "I tried to use the command "top", but it only listed actual top level processes, not PHP scripts." No PHP processes are listed there, as far as I've seen. Should I try something like "top php" ?
Tom
If php is not in the top then it is not running or it is lower in the list then you can see. As top only shows the first few processes. If your system has it you can use `pidof php`.
MitMaro
When I try "pidof php" I get "command not found".
Tom
Not all systems have it sadly. Try `ps -A | grep php`.
MitMaro
Tried, it returns nothing.
Tom
A: 

Re: ps not showing php processes

Keep in mind that a lot of hosts have a grid running and php processes are running on a different machine altogether. Depending on the configurations, these processes may never be visible to you via shell. You may have better luck with php scripts :)