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

 

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