OPENWRT Cron定時執行檢查LOG - Linux

By Queena
at 2018-04-14T14:03
at 2018-04-14T14:03
Table of Contents
感謝各位幫忙
完整版如下
System>Scheduled Tasks
每分鐘執行一次
*/1 * * * * sh /root/wifi_watchdog.sh
EX:
https://i.imgur.com/z5FI6sF.png
要把wifi_watchdog.sh放到/roor下面
#==================以下為wifi_watchdog.sh===================
#!/bin/sh
DATE=`date +%Y-%m-%d-%H:%M:%S`
#find the error message
dmesg|grep rt2x00queue_write_tx_frame>>/tmp/log.txt
#check the size if the log file
size=`du -a /tmp/log.txt|awk '{print $1}'`
if [ "$size" -gt "0" ]; then
echo $DATE Router reboot >>/root/wifi_watchdog.log
reboot
fi
#===========================================================
這樣就會每分鐘跑一次,只要抓到rt2x00queue_write_tx_frame錯誤
/tmp/log.txt 容量就會變大
然後,紀錄重啟時間點,重啟路由器
※ 引述《HiJimmy (嗨 吉米)》之銘言:
: 大家好~~
: 目前有一台MTK路由器
: 因為驅動的問題,無線都會不定時出錯
: 出錯就要重開才會正常
: 所以我想要用定時檢查
: 目前卡在條件判斷式的寫法
: cron 排程
: 1 0 0 0 0 /root/wifi_watchdog.sh
: 剛剛發現排程錯了 應該是
: */1 * * * * /root/wifi_watchdog.sh 一分鐘一次
: 批次檔
: #!/bin/sh
: #擷取網卡錯誤紀錄
: dmesg|grep rt2x00queue_write_tx_frame>>/tmp/log.txt
: #檢查檔案大小
: if [ du -a /tmp/log.txt>0]; then
: reboot
: fi
: 卡在檢查完大小,我不知道那個數字要比對大於零的寫法
: 目前這樣寫是過不了
: 有大於零代表出錯
: 我只要抓到有大於零就要重開機
: 這樣要如何撰寫
--
完整版如下
System>Scheduled Tasks
每分鐘執行一次
*/1 * * * * sh /root/wifi_watchdog.sh
EX:
https://i.imgur.com/z5FI6sF.png
要把wifi_watchdog.sh放到/roor下面
#==================以下為wifi_watchdog.sh===================
#!/bin/sh
DATE=`date +%Y-%m-%d-%H:%M:%S`
#find the error message
dmesg|grep rt2x00queue_write_tx_frame>>/tmp/log.txt
#check the size if the log file
size=`du -a /tmp/log.txt|awk '{print $1}'`
if [ "$size" -gt "0" ]; then
echo $DATE Router reboot >>/root/wifi_watchdog.log
reboot
fi
#===========================================================
這樣就會每分鐘跑一次,只要抓到rt2x00queue_write_tx_frame錯誤
/tmp/log.txt 容量就會變大
然後,紀錄重啟時間點,重啟路由器
※ 引述《HiJimmy (嗨 吉米)》之銘言:
: 大家好~~
: 目前有一台MTK路由器
: 因為驅動的問題,無線都會不定時出錯
: 出錯就要重開才會正常
: 所以我想要用定時檢查
: 目前卡在條件判斷式的寫法
: cron 排程
: 1 0 0 0 0 /root/wifi_watchdog.sh
: 剛剛發現排程錯了 應該是
: */1 * * * * /root/wifi_watchdog.sh 一分鐘一次
: 批次檔
: #!/bin/sh
: #擷取網卡錯誤紀錄
: dmesg|grep rt2x00queue_write_tx_frame>>/tmp/log.txt
: #檢查檔案大小
: if [ du -a /tmp/log.txt>0]; then
: reboot
: fi
: 卡在檢查完大小,我不知道那個數字要比對大於零的寫法
: 目前這樣寫是過不了
: 有大於零代表出錯
: 我只要抓到有大於零就要重開機
: 這樣要如何撰寫
--
Tags:
Linux
All Comments

By Daph Bay
at 2018-04-15T17:26
at 2018-04-15T17:26

By Olive
at 2018-04-16T22:02
at 2018-04-16T22:02

By Skylar Davis
at 2018-04-18T11:07
at 2018-04-18T11:07

By Anonymous
at 2018-04-18T13:19
at 2018-04-18T13:19

By Vanessa
at 2018-04-21T14:33
at 2018-04-21T14:33

By Queena
at 2018-04-24T07:44
at 2018-04-24T07:44

By Adele
at 2018-04-24T14:11
at 2018-04-24T14:11
Related Posts
OPENWRT Cron定時執行檢查LOG

By Queena
at 2018-04-14T09:32
at 2018-04-14T09:32
OPENWRT Cron定時執行檢查LOG

By Ivy
at 2018-04-14T08:59
at 2018-04-14T08:59
ubuntu 開指定版本matlab

By Wallis
at 2018-04-13T21:52
at 2018-04-13T21:52
讓 AMDGPU 當 amdgpu.dc=1 時輸出 RGB 格式的方法

By Charlie
at 2018-04-13T16:00
at 2018-04-13T16:00
求救,ubuntu16裡 /dev/sda1空間不夠了

By David
at 2018-04-12T15:13
at 2018-04-12T15:13