2018-08-16 10:56
浏览 289

从crontab运行时,PHP exec不返回LFTP输出

I have a PHP file (/path/to/file.php) containing an exec-command:

$result = exec('lftp -u USER,PASS sftp://USER@IP:PORT -e "cd FOLDER; mput -E FILE; quit;"');

When I run the command "php /path/to/file.php" in the terminal, $result has a value "X bytes transferred"

When I create a cron task for the same user using the exact same command, the $result is always an empty string. The command still works though, the file can be found on the FTP-server.

How can I get the cron version to output something so I can confirm that the transfer was succesfull?

图片转代码服务由CSDN问答提供 功能建议


  $ result = exec('lftp -u USER,PASS sftp:// USER @ IP:PORT -e“cd FOLDER; mput -E FILE; quit;”'); \  n   

当我在终端中运行命令“php /path/to/file.php”时,$ result的值为“X bytes transferred”

当我使用完全相同的命令为同一用户创建cron任务时,$ result始终为空字符串。 该命令仍然有效,该文件可以在FTP服务器上找到。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douzhe9927 2019-04-24 11:56

    So the solution was to add the following setting to a LFTP config file (for example /etc/lftp.conf):

    set cmd:interactive yes

    解决 无用
    打赏 举报

相关推荐 更多相似问题