Cron expression for every sept working day - cron

How to create a cronexprrssion for ever 1st September working day. It means omit Sunday

Based on the format:
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
This should make it:
+---------------- at minute 0
| +------------- at hour 0
| | +---------- at day 1
| | | +------- at month 9 -> September
| | | | +---- at day 1 to 6, that is, all but Sunday
| | | | |
0 0 1 9 1-6 /your/path/ /your/script

If you want what #Duncan said (a cron expression that finds the first working day in September), then this should do:
0 0 0 1W 9 ? *
Results:
Tuesday, September 1, 2015
Thursday, September 1, 2016
Friday, September 1, 2017
Monday, September 3, 2018
Monday, September 2, 2019

Related

How to get the week number for day irrespective of the calender week number?

how to get the week number for the day irrespective of the calender week in excel?
Iam looking for the column "nth_week_number" .In the below table "2/5/2018" will fall in the 2nd week of the Feb 2018 but It was a 1st Monday of that Month.
Someone please help to resolve this in excel.
| Date | Weekday | week _of_the_month | nth_week_number |
|-----------|-----------|--------------------|-----------------|
| 2/1/2018 | Thursday | 1 | 1st Thrusday |
| 2/2/2018 | Friday | 1 | 1st Friday |
| 2/3/2018 | Saturday | 1 | 1st Saturday |
| 2/4/2018 | Sunday | 2 | 1st Sunday |
| 2/5/2018 | Monday | 2 | 1st Monday |
| 2/6/2018 | Tuesday | 2 | 1st Tuesday |
| 2/7/2018 | Wednesday | 2 | 1st Wednesday |
| 2/8/2018 | Thursday | 2 | 2nd Thrusday |
| 2/9/2018 | Friday | 2 | 2nd Friday |
| 2/10/2018 | Saturday | 2 | 2nd Saturday |
| 2/11/2018 | Sunday | 3 | 2nd Sunday |
| 2/12/2018 | Monday | 3 | 2nd Monday |
| 2/13/2018 | Tuesday | 3 | 2nd Tuesday |
Try this formula in row 2 and copy it down:
=(ROUNDUP(DAY(A1)/7;0)&". "&TEXT(A1;"dddd"))
This will output 2. Thursday for example, formatting it as 1st, 2nd, 3rd, etc. would require a bit more work. Please note that you might have to change the semicolons ; to regular commas , in an English version of Excel (I think).
Edit: Updated formula to fit your exact case, as suggested by #Ron Rosenfeld:
=(CHOOSE(ROUNDUP(DAY(B1)/7;0);"1st ";"2nd "; "3rd "; "4th "; "5th ")&TEXT(B1;"dddd"))

Generate cron expression for two years

I need to generate cron expression for every 10 min in the date range October 2017 to Feburary 2018.
I tried the following expression:
0 10 0 ? 10-2 * 2017-2018,
But its not a valid expression. I get this error message:
((Month) - Unsupported value '10-2' for range. ),
Please help.
Try to use this:
*/10 * * 2-10 * 2017,2018 command here
from nncron.ru page:
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
if you want to test other format, use this page http://cronsandbox.com/

Run cronjob specific hours/days

I have a cronjob on my server which runs every hour all the days of the week
0 * * * *
I want to run it 09.00 - 21.00 and only from Monday to Friday
Refer this
* * * * * Command to be executed
- - - - -
| | | | |
| | | | +----- Day of week (0-7)
| | | +------- Month (1 - 12)
| | +--------- Day of month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Min (0 - 59)
I want to run it 09.00 - 21.00 and only from Monday to Friday
Answer should be
* 9-21 * * 1-5

Unable to understand the particular format of Cron?

I have read the CronFormat to understand the Cron.But I am unable to understand this Cron Format:
According to my understand,the format is
<Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
But I am unable to understand the below format.
07/10 * 1/1 *?*
My Understanding:
My understanding of the above format is:
After Every 7 Minute,every hour and every month and every year.
Can anyone guide me what is it?
QuestionMark(?) and * I have not understood
This is format of each cron job
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
so 7/10 means 7th minute of every 10 minute,
next * means every hour,
1/1 also means every so every day.
Unfortunately I am also not aware of "?".
I like this example its easy for me to understand :-
# Minute | Hour | Day of Month | Month | Day of Week | Command
# (0-59) | (0-23) | (1-31) | (1-12 or Jan-Dec) | (0-6 or Sun-Sat)
0 | 2 | 12 | * | * | /usr/bin/find

whats the cron format for the following

I need to run bash script at 2nd Sat of the month at 11pm.I cant figure out its cronformat.
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
This is the cronformat i found from the internet but i am new to this and i think this problem is kind of tough.
Arg i waited so many days for the solution but not a single comment nor an answer. Anyway i think the answer is
0 23 8-14 * Sat
please correct me if i am wrong.
Run the cron every Saturday and only execute the script on the second Saturday:
* * * * 6 * test $(expr $(date +\%d) / 7) -eq 2 && <execute script here>

Resources