Solve the problem that shell_exec() fails to execute Shell script in Web program in PHP

藏色散人
Release: 2023-04-08 07:14:02
forward
4670 people have browsed it

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!

Related labels:
php
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template