php shell_exec($ cmd)不能在cronjob中运行 [英] php shell_exec($cmd) do not run in a cronjob

查看:156
本文介绍了php shell_exec($ cmd)不能在cronjob中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉(我相信)这个可怜的问题,但是Google和此论坛中的其他文章对我没有帮助...

sorry for that (I believe) poor question, but google and other articles in this forum can't help me...

我将在其中运行以下代码的php脚本:

I'll run the a php script with following code in it:

    $cmd="duck  -u user_name -p pwd -parallel 1 -e overwrite -y --throttle 1024 --upload path to remote file absolute_path_to_local_file";
    $shellResponse=shell_exec($cmd);

当我在浏览器中调用此php文件时,此方法运行良好. 但是,当我在cronjob中调用脚本时,它失败了.

This works well, when I call this php file in the browser. But it fails, when I call the script within a cronjob.

使用cronjob时,我收到以下错误消息:

With a cronjob i get following errormessage:

sh:1: duck not found

我认为这可能是权限问题,但是我是该领域的新手,不知道可以在哪里设置权限以及必须执行的操作.

I believe this can be a permissions problem, but I'm new in this area and do not know where I can set the permissions and what I have to do.

有人可以帮我吗?!

推荐答案

Cron作业无法获取通常可用的普通PATH env变量.

Cron jobs do not get the normal PATH env variable that is usually available.

尝试对"duck"命令使用绝对路径.

Try using the absolute path for the 'duck' command instead.

示例:

$cmd = "/usr/bin/duck ..."

要找到绝对路径,可以键入

To find the absolute path, you can type

which duck

在常规命令提示符下

这篇关于php shell_exec($ cmd)不能在cronjob中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆