当管道传输到文件时,Cron 作业输出 php headers
Cron job outputting php headers when piping to file
我有一个 bash 脚本,其中 运行s 4 命令并重定向到一个文件。当我从我的服务器上的 CLI 自己 运行 时,这个脚本工作正常。当我让 cron 运行 脚本时它不起作用。
我的文件看起来像这样:
#!/bin/bash
command > file.csv
command >> file.csv
command >> file.csv
command >> file.csv
我自己 运行 时得到了预期的结果,但是当 cron 运行 时我得到了这个:
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
有人可以帮忙吗?快把我逼疯了....
解决方案是在 bash 脚本中指定路径 属性。
我在 shell 中回显了 $PATH 变量并将其复制到脚本中,这似乎解决了问题。
我有一个 bash 脚本,其中 运行s 4 命令并重定向到一个文件。当我从我的服务器上的 CLI 自己 运行 时,这个脚本工作正常。当我让 cron 运行 脚本时它不起作用。
我的文件看起来像这样:
#!/bin/bash
command > file.csv
command >> file.csv
command >> file.csv
command >> file.csv
我自己 运行 时得到了预期的结果,但是当 cron 运行 时我得到了这个:
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
有人可以帮忙吗?快把我逼疯了....
解决方案是在 bash 脚本中指定路径 属性。
我在 shell 中回显了 $PATH 变量并将其复制到脚本中,这似乎解决了问题。