每月最后一周的周六晚上21:00执行任务-crontab

0 21 * * 6 /bin/sh /root/time.sh            #"6"代表周六

 时间判断脚本如下:

#!/bin/bash
if [ "$(date -d "+7 days" +%d)" -gt "$(date +%d)" ]             #如果是每月第一周将"-gt"该为"-lt"
    then
        echo "False"
else
        /bin/sh /root/server.sh
fi

  

原文地址:https://www.cnblogs.com/a120608yby/p/9882935.html