shell指令碼清空系統message日誌

2021-07-24 04:59:54 字數 515 閱讀 9690

1 #/bin/bash

2 #此指令碼用來清空系統message日誌檔案

3 #author:wyf date:16/10/30

4 log_dir=/var/log

5 root_uid=0

6 #必須系統管理員許可權才能執行

7 if [ "$uid" -ne "$" ]

8 then

9 echo "must be root to run this script"

10 exit 1

11 fi

12 #切換目錄不成功則將錯誤資訊輸出到標準錯誤輸出

13 cd $ ||

17 #清空日誌檔案

18 cat /dev/null >messages

19 echo "logs cleand up"

20 exit 0

放在定時任務裡面執行,定時清空系統的message檔案,還是挺實用的。

使用Shell指令碼刪除 清空日誌檔案

話不多少,直接上 bin bash workdir home tax punish ret log txt 可填寫多個路徑,用空格隔開 查詢日誌檔案 for wdir in do echo filepath is wdir if wdir then filestr find wdir log ech...

使用shell指令碼清空mysql指定的多張表資料

1.指令碼 bin bash program 定義連線變數 host str 172.16.16.64 port 3306 username admin password admin database cmom trunk 1 mysql conf cat config mysql.conf con...

使用Shell指令碼刪除 清空日誌檔案

話不多少,直接上 bin bash workdir home tax punish ret log txt 可填寫多個路徑 用空格隔開 查詢日誌檔案 for wdir in doecho filepath is wdir if wdir then filestr find wdir log echo...