当使用PHP Exec方法时,如何知道Shell Scitpt成功执行
我正在使用PHP中的EXEC运行shell脚本,EXEC已成功执行并给出0作为结果代码。是否有任何方法可以成功执行所有Shell脚本?
I am running shell script using exec in php, exec is successfully executes and give 0 as result code. is there any way to check all shell script is executed successfully or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果退出代码为零,则脚本成功运行到其目的。
退出代码HOWOVER并不意味着您的Shell脚本在内部工作,而是没有执行。每当您想声明出现问题时,返回有效的退出代码是您的Shells脚本的责任。
此外,最好用
退出0
表明您的脚本运行而没有错误,这是一个很好的做法。出口代码<> 0意味着这完全取决于您。例子:
If the exit code is zero, then the script ran successfully to it's end.
The exit code code howover does not imply that your shell script worked internally, but rather it did not fail to execute. It is your shells script's duty to return a valid exit code whenever you want to state that something went wrong.
Furthermore it is good practice to explicitly quit with
exit 0
to state that your script is ran with no error. What an exit code <> 0 means it totally up to you.Example: