[英]How to check if Mailx used in the past timeframe?
我有一個mailx語句作為shell scipt的一部分。 它是條件聲明的一部分,如果系統出現故障,它將每分鍾發送一封電子郵件。
有沒有辦法讓mailx檢查郵件是否在過去一小時內發送,只有在結果為假時才發送?
tail -1 "/location/of/file.txt" | mail -s "Warning" test@testing.com;
使用文件標記您發送的時間。 例如
dowork() {
tail -1 "/location/of/file.txt" | mail -s "Warning" test@testing.com;
touch ./checked.txt
}
if [[ -f ./checked.txt ]] ; then
if [[ $(expr $(date '+%s') - $(stat -c '%Y' ./checked.txt )) -gt 3600 ]]; then
dowork
fi
else
dowork
fi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.