我想在到期日前四个星期发送续订提醒电子邮件。我将所有详细信息存储在一个数组中,但我不知道如何检查今天的日期是否比数组中的日期早 28 天。
这是我到目前为止所得到的,任何有关如何进行日期检查的帮助将不胜感激:
#!/bin/sh
adminemail="me@gmail.com"
account[1]="June 03|john@gmail.com|John"
account[2]="April 17|jane@gmail.com|Jane"
account[3]="November 29|sarah@gmail.com|Sarah"
for check in "${account[@]}"
do
renew=$(echo $check | cut -f1 -d\|)
email=$(echo $check | cut -f2 -d\|)
name=$(echo $check | cut -f3 -d\|)
# check date is 28 days away
if [ ?????? ]
then
subject="Your account is due for renewal"
text="
Dear $name,
Your account is due for renewal by $renew. blah blah blah"
echo "$text" | mail -s "$subject" $email -- -r $adminemail
fi
done