以下的脚本用了数字的比较。
以下脚本放在周日用cron来执行,如果星期的数是偶数的话,就提醒把垃圾箱清理一下。
#!/bin/bash
# Calculate the week number using the date command:
weekdate=$[ $(date +"%V") % 2 ]
# Test if we have a remainder. If not, this is an even week so send a message.
# Else, do nothing.
if [ $weekdate -eq "0" ]; then
echo "Sunday evening, put out the garbage cans." | mail -s "laji qing li"
# Calculate the week number using the date command:
weekdate=$[ $(date +"%V") % 2 ]
# Test if we have a remainder. If not, this is an even week so send a message.
# Else, do nothing.
if [ $weekdate -eq "0" ]; then
echo "Sunday evening, put out the garbage cans." | mail -s "laji qing li"
fi
打开邮件如下图:
日期可以自己定。
供学习!!!
本文转自 zhangzj1030 51CTO博客,原文链接:http://blog.51cto.com/tech110/233914