shell if脚本

shell脚本 根据接口返回结果 来执行另一个shell脚本 

#!/bin/bash

RESULT=$(curl https://www.aa.com/admin/index/index)
#echo $RESULT;

if [[ $RESULT = 'runing' ]];
then
  echo "runing~~";
elif [[ $RESULT = 'stop' ]] ;
then
  echo "stop~~";
   /var/www/bb.sh;
   #执行另一个shell脚本
else
  echo "Data Is Error."
fi

 

使用crontab 来定时访问这个接口,达到实时检查这个接口返回值,来执行另一个shell脚本(bb.sh)中的命令

crontab -e

*/30 * * * * cd /var/www && ./aa.sh

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章