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