Crontab没有按预期工作

时间:2015-03-04 09:23:18

标签: linux shell crontab

#/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 - 请建议,IN crontab,似乎条件不起作用。

1 个答案:

答案 0 :(得分:0)

Crontab不会使用与您的用户相同的环境变量执行作业。

所以它不知道在哪里查找二进制文件(PATH没有定义不同的)。您必须仅使用绝对路径而不是相对路径来执行命令。

例如,将wget替换为/usr/bin/wget

相关问题