linux判斷日誌檔案大小進行清理

2022-01-18 06:58:11 字數 477 閱讀 9930

指令碼寫了乙個死迴圈,根據nohup產生的日誌多大, 這裡表示日誌超過500m之後清理, 具體數字可自定義

睡眠數可自定義

#!/usr/bin/bash

while true

dos=`du -k nohup.out|awk ''`

chengdatetime=`date "+%y-%m-%d %h:%m:%s"`

if [ $s -gt 500000 ]

then

echo $chengdatetime":檔案超過預定大小,開始清理日誌"

cat /dev/null > nohup.out

else

echo "繼續迴圈..."

做個筆記。

日誌檔案大小限定

include include include include getpid include time.h include stdarg.h include syslog.h define log file name len 64 define log max size 128 define log...

Delphi判斷檔案大小

delphi自身提供了filesize函式,例如 var f file of byte size longint begin assignfile f,f t.exe reset f size filesize f edit1.text inttostr size closefile f end 這...

liunx判斷檔案大小

ls l grep wc l 或find company type f wc l 檢視某資料夾下檔案的個數,包括子資料夾裡的。ls lr grep wc l 檢視某資料夾下資料夾的個數,包括子資料夾裡的。ls lr grep d wc l 說明 ls l 長列表輸出該目錄下檔案資訊 注意這裡的檔案,...