phpexecshell-execcyberduck

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


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?!


Solution

  • 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