【问题标题】:Cron job outputting php headers when piping to file管道到文件时输出 php 标头的 Cron 作业
【发布时间】:2019-08-19 21:10:06
【问题描述】:

我有一个 bash 脚本,它运行 4 个命令并重定向到一个文件。当我从服务器上的 CLI 自己运行此脚本时,它运行良好。当我让 cron 运行脚本时它不起作用。

我的文件看起来像这样:

#!/bin/bash
command > file.csv
command >> file.csv
command >> file.csv
command >> file.csv

当我自己运行它时,我得到了预期的结果,但是当我运行它时,我得到了这个:

X-Powered-By: PHP/7.1.31
Content-type: text/html; charset=UTF-8

X-Powered-By: PHP/7.1.31
Content-type: text/html; charset=UTF-8

X-Powered-By: PHP/7.1.31
Content-type: text/html; charset=UTF-8

X-Powered-By: PHP/7.1.31
Content-type: text/html; charset=UTF-8

我这样执行 cron 作业:

/usr/bin/php -q /home/user/rest/of/path/script.sh >/dev/null

有人可以帮忙吗?快把我逼疯了……

【问题讨论】:

标签: php bash cron cpanel


【解决方案1】:

解决方案是在 bash 脚本中指定 PATH 属性。

我在 shell 中回显了 $PATH 变量并将其复制到脚本中,这似乎可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-10
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 2017-09-05
    • 2012-04-28
    相关资源
    最近更新 更多