for Linux
0 8 28-31 * * [ `date -d tomorrow +\%e` -eq 1 ] && do-something
for other Unix,BSD
0 8 28-31 * * [ `echo \`cal\` | awk '{print $NF}'` -eq 1 ] && do-something
More, run cron jobs at last workday of the month
0 8 26-31 * * root [ `echo \`cal | cut -d' ' -f2-6\` | awk '{print $NF}'` -eq `date +%e` ] && do-something
ref. 系统管理員工具包: 時間和事件管理
Leave a comment