簡體   English   中英

Crontab作業調度不起作用

[英]Crontab job scheduling is not working

我有從遠程數據庫中提取一些數據並寫入文本文件的腳本。 此文本文件用於填充本地數據庫。

如果我運行單個腳本,它將按預期工作(使用記錄更新文本文件)。

如果在crontab中添加了此腳本,則無法正常工作。

Crontab表達式:

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

輸出在/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命令。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM