shells scipt の一部として mailx ステートメントがあります。これは、システムに障害が発生した場合に毎分電子メールを送信する条件付きステートメントの一部です。
過去 1 時間にメールが送信されたかどうかを mailx に確認させ、結果が false の場合にのみ送信する方法はありますか?
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