当从命令行运行时脚本运行正常,但不通过cron(script runs fine when run from command line but not via cron)

编程入门 行业动态 更新时间:2024-10-25 22:33:49
当从命令行运行时脚本运行正常,但不通过cron(script runs fine when run from command line but not via cron)

我有一个运行良好的php脚本,通过SSH进入我的服务器并运行它。

然而,即使一个cron作业设置为每10分钟运行一次,php脚本也不会运行。

如何查看cron作业产生的错误?

i have a php script which runs fine when executed by SSHing into my server and running it.

however the php script doesn't seem to run even though a cron job set to run it every 10 minutes.

How do I view errors produced by cron job ?

最满意答案

请记住,cron在不同于你以前使用的工作目录中运行你的脚本。 在命令行上尝试如下所示:

cd / ./path/to/your/script.php

如果失败,请正确修改脚本中的所有路径,直到它运行。 然后它将在cron中运行。

Remember that cron runs your script in a different working directory than what you're probably used to. Try something like the following on the command line:

cd / ./path/to/your/script.php

If it fails, modify all paths in your script correctly until it runs. Then it will run in cron.

更多推荐

本文发布于:2023-07-21 09:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但不   命令行   脚本   cron   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!