简体   繁体   中英

PHP Can't Execute Shell Script That Kills Process

I have a script called turn_on.sh . I also have a script turn_off.sh .

turn_on.sh 

Starts a process

turn_off.sh

Simply kills the process (via kill -9 pid)

Running on the command line, everything works fine.

Calling these scripts from php simply doesn't work. I've tried shell_exec , exec , system . Nothing seems to work. There is no errors anywhere.

I've tried chmod 777 both shell scripts. Still doesn't work.

Example code:

   $val3 = exec($to_run,$val2,$val);

$val2 and $val having nothing in them.

PHP safe_mode is off

This may be due to several reasons:

1) You run your PHP script via apache, so the www-data user didn't have permission to run the two shells scripts.

2) You run your PHP script via apache, so the www-data user didn't have permission to start or kill the process.

3) ...

Try to redirect the standard and error outputs of your scripts in a log file for better analysis. You could also use set -x to get a more complete debug trace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM