#!/bin/bashfunc(){ wget ... touch finished}func &sleep 3000if [ -f finished ]then echo "finished"else echo "not finished"firm -f finished
touch命令有两个功能:一是用于把已存在文件的时间标签更新为系统当前的时间(默认方式),它们的数据将原封不动地保留下来;二是用来创建新的空文件。
#!/bin/bash
cd /home/oracle/monitor
func()
{
/u02/BIEE12C/user_projects/domains/bi/bitools/bin/datamodel.sh listconnectionpool -SI ssi -U Administrator -P Admin123|grep "Spark BIEE"
if [ $? -eq 0 ]; then
touch obis1return
echo "obis1return>>>>>>>>>>"
fi
}
func &
sleep 15
if [ ! -f obis1return ]; then
echo `date '+%Y-%m-%d %H:%M:%S'`"BIEE obis1 is stucked"
rm -f obis1return
elseecho `date '+%Y-%m-%d %H:%M:%S'`"BIEE obis1 is normal"
rm -f obis1return
fi
本文介绍了一个使用Bash脚本实现的任务监控解决方案。通过定义一个后台运行的函数执行特定命令,并利用sleep和条件判断来检查任务是否完成,最终清除状态文件。此脚本还展示了touch命令的使用方法,用于标记任务完成状态。

539

被折叠的 条评论
为什么被折叠?



