Oracle regular run data

Source: Internet
Author: User

Select to_char (add_months (last_day (sysdate) + 1,-1), 'yyyymmdd'), to_char (last_day (sysdate) + 1, 'yyyymmdd') from dual;

00 22 ***['Echo \ 'cal \ '| awk & apos; {print $ NF} & apos; '-EQ 'date + \ % d'] & do-something (do two at the end of each month. sh file to prevent one of them from being executed successfully)
Assume that your_cmd_fullname is executed at 08:10 on the last day of each month
[Code] For (I = 1; I <= 12; I ++); Do Cal $ I 2004 | sed '/^ $ \ | 2004 \ | ^ Su. */d' | sed-E: A-E 'n'; S/\ N //; TA '| SED's /. * \ ([0-9] [0-9] \) $/\ 1/'; done | awk' {A [$0] = sprintf ("% s, % s ", a [$0], NR)} end {for (I in a) printf (" 10 8% d % S * your_cmd_fullname \ n ", I, A [I])} 'days | SED's/, // '[/Code]
Execution result
[Code] 10 8 29 2 * your_cmd_fullname
10 8 30, 6, 9, 11 * your_cmd_fullname
10 8 31 1, 3, 5, 7, 8, 10, 12 * your_cmd_fullname [/Code]
Then add the code to your crontab.
Linux --- shell:

#! /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

How to express the last day of each month in crontab?

Execute every day and make judgment in the program header to be executed. Exit if it is not the end of the month

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.