簡體   English   中英

Crontab無法正常工作

[英]Crontab not working as expected

#/bin/bash
cd /home/oracle/scripts/mon_scripts/
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=test
cat /dev/null > /home/oracle/scripts/mon_scripts/wget_cache.out
a=`sqlplus test/test123@/home/oracle/scripts/mon_scripts/flushtable.sql|grep -A 2 COUNT|tail -n1`
if [ $a == 0 ];then
(
echo "Empty- Nothing Processed"
)
else
(
echo "localhost" >> wget_cache.out
ssh localhost wget http://localhost/cs/ContentServer?pagename=debug/ReloadRefData -O - >> wget_cache.out
echo "--------------" >> wget_cache.out
echo "localhost" >> wget_cache.out
wget http://localhost:7005/cs/ContentServer?pagename=debug/ReloadRefData -O - >> wget_cache.out
echo "--------------"
echo "localhost" >> wget_cache.out
wget http://localhost:7005/cs/ContentServer?pagename=debug/ReloadRefData -O - >> wget_cache.out
sqlplus test/test123 @/home/oracle/scripts/mon_scripts/deletetable.sql
)
fi

上面的腳本在命令提示符下運行正常,但是在使用crontab時無法正常工作-請在crontab中建議,如果條件不正常,則建議使用該腳本。

Crontab不會使用與您的用戶相同的環境變量來執行作業。

因此它不知道在哪里尋找二進制文件( PATH的定義不同)。 您只需使用絕對路徑,而不必使用相對路徑來執行命令。

例如,將wget替換為/usr/bin/wget

暫無
暫無

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

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