有index.php文件,其中包含代码:
header("Location: /from_index.php"); # 重定向(from_index.php的文件位置在:/www/)
使用crontab -e加入定时任务:
*/5 9-23 * * * sleep 50 && php /www/index.php # php脚本的绝对路径
请问这样的结构中,会执行from_index.php中的代码吗?
我了解到如果写成:
*/5 9-23 * * * sleep 50 && curl -L -e '; auto' http://127.0.0.1/index.php # http访问
是能够执行到from_index.php中的代码的。但是这样的写法是否没有使用php命令效率高?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
如果使用curl的话你需要打开它的重定向开关
curl 不可以使用 header
直接再在代码里面用 system 调用php命令执行那个php文件 不可以这样?
第一个问题,不会,
第二个,不会有直接执行cli的性能高