Crontab作业调度无效

时间:2015-12-02 11:30:05

标签: linux bash shell crontab scheduling

我有脚本从远程数据库中提取一些数据并写入文本文件。 此文本文件用于填充本地数据库。

如果我运行单个脚本,它按预期工作(用记录更新文本文件)。

如果在crontab中添加此脚本,则无效。

Crontab Expression:

0 * * * * /usr/bin/todb >>/usr/bin/mycommand.log 

观察:文本文件时间戳将在预定时间内更改,但不会更新记录。(O字节),它也适用于mycommand.log文件。

Bash脚本:

file="/usr/bin/todb.txt"
if [ -f "$file" ]
then
rm /usr/bin/todb.txt 
fi
engineers_list=( abc 123 hjk )
for i in "${engineers_list[@]}"
do
    fing -s JKL  "( ( [Duplicate-on] >= 06/01/2014  ) and  [Engineer] = '$i' )" -w Identifier,DE-manager,Engineer -D ^ >> /usr/bin/todb.txt
done

1 个答案:

答案 0 :(得分:1)

输出位于/usr/bin/todb.txt文件中,而不是/usr/bin/mycommand.log

触摸

/usr/bin/mycommand.log(并更改时间戳)bt将所有输出重定向到/usr/bin/mycommand.log

命令

/usr/bin/todb >> /usr/bin/mycommand.log

仅将stdout重定向到mycommand.log。要重定向stdoutstderr,请尝试:

/usr/bin/todb >> /usr/bin/mycommand.log 2>&1

我猜您的脚本找不到fing命令。

相关问题