Crontab executed on the last day of each month

Source: Internet
Author: User
How to set crontab to run on the last day of each month: forLinux0828-31 ** ['date-dtomorrow + \ % e'-eq1] & amp; (shellscript) forotherUnix, BSD0828-31 ** ['echo \ 'Cal \ '| aw...

How to set crontab to execute on the last day of each month:
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)

Another method:
It is complicated to judge by crontab alone, so the judgment part is written into the execution script.
#! /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

Author: "java-2007"
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.