php shell_exec($cmd) do not run in a cronjob

自作多情 提交于 2019-12-10 11:43:14

问题


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

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);

This works well, when I call this php file in the browser. But it fails, when I call the script within a 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.

Can anybody please help me?!


回答1:


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

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

Example:

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

To find the absolute path, you can type

which duck

on a normal command prompt



来源:https://stackoverflow.com/questions/46934471/php-shell-execcmd-do-not-run-in-a-cronjob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!