crontab每月最后一天执行

如何设定crontab在每月最后一天执行一种方法:
for Linux
0 8 28-31 * * [ `date -d tomorrow +\%e` -eq 1 ] && (shell script)
for other Unix,BSD
0 8 28-31 * * [ `echo \`cal\` | awk '{print $NF}'` -eq 1 ] && (shell script)



另一种方法:
单独靠crontab判断比较复杂,所以把判断部分写到执行脚本中
#!/bin/bash
today=`date +%d`
last_day=`cal | xargs | awk '{print $NF}'`
if [ "$today" != "$last_day" ];then   
 exit 1
fi
....  # other codes start from here

原文地址:https://www.cnblogs.com/aggavara/p/2767851.html