每月最后一天执行shell

    技术2022-05-20  95

    如何实现每月的最后一天执行一个shell

     

    脚本中判断的话,可以像这么写:ym=`date +%m" "%Y`

    if [ `date +%d` = `cal $ym|xargs|awk '{print $NF}'` ]

      then

           sh yourshell

    fi

    linux版的

    00 23 28-31 * * [ `date -d tomorrow +/%e` -eq 1 ] && do-something

     

    UNIX版的0 8 28-31 * * [ `echo /`cal/` | awk '{print $NF}'` -eq 1 ] && do-something


    最新回复(0)