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
Related
I scheduled some jobs in crontab. They are not even running. I also checked with logs along with schedules log file is not even created.
I am getting some EOF error. I think i made some changes in /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# 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
my corntab
35 04 * * * cd /home/ec2-user/cerberus/src/automation_scripts/act/ && sh active.sh >> /home/ec2-user/cerberus/logs/active/`date "+%Y-%m-%d"` 2>&1
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/
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
i have a crontab line and i want to ask some expert what this line will do
10,40 * * * * sh /etc/test/script.sh
please tell me what will 10,40 do in this crontab -e file.i am new to crontab use
* * * * * command
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday = 0)
| | | +------- month (1 - 12)
| | +--------- day (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
each position takes a comma-separated list of values.
this will execute sh /etc/test/script.sh at :10 and :40 every hour.
00:10, 00:40, 01:10, 01:40, ...
additionally
you can use / to specify an interval, i.e.
*/5 * * * * sh /etc/test/script.sh
to run it every 5 minutes.
wikipedia cron page
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>