gpt4 book ai didi

linux - 用于检查最新 ZFS 快照的 Shell 脚本

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:08:46 25 4
gpt4 key购买 nike

我正在运行常规快照 (zfs snapshot tank/name@$date)。

这很好用,但是,我想添加更多的智能。特别是,我想运行一个 cron 来检查最新的快照,如果快照早于 X 天,则发送电子邮件警报。

有什么想法吗?

最佳答案

status=$( zfs list -t snapshot -o name,creation -s creation -r tank/vm | tail -1 | cut -d ' ' -f 4,5,6,7,8,9 )

datenow=$( date +"%b %d %H:%M %Y" )

first_date=$(date -d "$datenow" "+%s")
second_date=$(date -d "$status" "+%s")

datediff=$(( ($first_date - $second_date)/(period=$((60*60))) ))
if [ "$datediff" -ge "1" ]
then
command to mail
else
command for mail
fi

享受 :)

关于linux - 用于检查最新 ZFS 快照的 Shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41328041/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com