【发布时间】: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
有人可以帮忙吗?快把我逼疯了……
【问题讨论】: