且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

bash脚本运行PHP脚本

更新时间:2023-01-31 20:02:23

如果您已经安装PHP作为一个命令行工具(试行发放 PHP 到终端看看它的工作原理),你的家当()行需要看起来像这样:

If you have PHP installed as a command line tool (try issuing php to the terminal and see if it works), your shebang (#!) line needs to look like this:

#!/usr/bin/php

把,在你的脚本的顶部,使其可执行(搭配chmod + X myscript.php ),使一个cron作业来执行脚本(相同的方式,倒是执行bash脚本)。

Put that at the top of your script, make it executable (chmod +x myscript.php), and make a Cron job to execute that script (same way you'd execute a bash script).

您也可以使用 PHP myscript.php