Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 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