【发布时间】:2014-09-13 12:05:56
【问题描述】:
我有一个简单的 Bash 脚本,可以很好地从命令行运行。它需要写入脚本开头附近的两个临时文件。当我将它放在 cronjob 中时,它会创建临时文件,但不会向其中写入任何数据。这些文件的大小为零。每次 cron 作业重新启动时,我都希望覆盖临时文件。
cron 条目基本上是这样的:
0 */4 * * * /opt/myscripts/boringScript.sh
脚本中是:
...
echo "Starting boring inventory script" >> /opt/myscripts/boringScriptLog.out
countingScript.sh | grep $paramONE | sed s#\ ##g > tempResults1.txt
countingScript.sh | grep $paramTWO | sed s#\ ##g > tempResults2.txt
do
// more stuff with the above temp files
...
done
...
知道为什么它不会将任何数据写入 cron 中的临时文件吗?
谢谢!
【问题讨论】:
-
您应该指定
countingScript.sh的完整路径。如果它在您的主目录中,您可能仍需要使用./countingScript.sh或~/countingScript.sh指定路径。