方法1:利用腳本調取腳本方式
[root@crushlinux ~]# crontab -e 00 17 1 * * /opt/cron.sh [root@crushlinux ~]# vim /opt/cron.sh echo "30 17 $(cal | awk 'NR==3{print $NF}') $(date +%m) * /opt/shell.sh" >> /var/spool/cron/root
方法2:獲取每月第一個周日的日期與當天日期進行判斷
[root@crushlinux ~]# crontab -e 30 17 * * 6 [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /opt/shell.sh
方法3:利用日期范圍形式(取巧)
[root@crushlinux ~]# crontab -e 30 17 * * 6 [ $(date +%d) -lt 7 ] && /opt/shell.sh