Home > Article > Backend Development > Solve the problem that shell_exec() fails to execute Shell script in Web program in PHP
Question
Today I discovered that when using a timer, a shell script is executed and the log is printed normally, but the result of the current shell script execution cannot be found in the system.
Because I am using a Web program, I am also new to Shell calling. I have never encountered this problem before, so I can only guess.
Judgment
1. Shell script problem.
Verification method: Enter the system console, and then call the script directly to verify that the script is normal. Troubleshoot the script itself.
2. Determine whether the problem comes from permissions
Verification method: Enter the console and view the execution log author.log. Sure enough, it prompted that there was a problem with the account permissions.
ls Check the Shell script information and find that the user of the web program and the authorized user of the Shell script are not the same account. Modify it to the same account and start the program again to solve the problem.
Conclusion:
Similar problems are basically caused by the above two aspects. When there are exceptions, check the logs. Basically, all problems will be printed out.
For more PHP related knowledge, please visit PHP Tutorial!
The above is the detailed content of Solve the problem that shell_exec() fails to execute Shell script in Web program in PHP. For more information, please follow other related articles on the PHP Chinese website!