dont understand cron. What is 56 11 * * * /usr/sbin/update-file.sh - linux

What does this command mean in cron? How often will this run? When will it run? Will it run daily?
56 11 * * * /usr/sbin/update-file.sh

From crontab(5):
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
Thus, your line means to run /usr/sbin/update-file.sh every day at 11:56 AM.

Crontab format is: minute, hour, day of month, month, day of week, command.
So this will run /usr/sbin/update-file.sh at 11:56 AM every day.

Related

Cron periodicity works unclear with month days

I have expression 0 0 6/2 * *
it will run anything every second day starting from 6 day of month and in next month it can be earlier than 6 day? Example cron runs:
2022-06-06
2022-06-08
2022-06-10
...
2022-06-26
2022-06-28
2022-06-30
2022-07-02
2022-07-04
2022-07-06
2022-07-08
...
Does it work like this or cron run only from 6 day every month?
From here
At 12:00 AM, every 2 days, starting on day 6 of the month
So no, it will start on 6th day of month and then every 2 days

Cron expression for 24 hour period

I'm trying to write a crontab expression that will begin a specified period of time and run on an interval for a 24 hour period. For example I want the job to run every Thursday beginning at 4 PM and repeat every hour for 1 day. Is there a way to do this? Everything I have tried stops at the end of the day Thursday.
You need two crontab entries, one for the occurrences on Thursday and one for the occurrences on Friday.
For example (I have not tested this):
0 16-23 * * 4 your_command
0 0-15 * * 5 your_command
The fifth column is the day of the week, with Sunday=0. (Vixie cron also lets you specify the day of the week by name.)

Cron job syntax debian

33 */27 * * * python /root/get_top.py
Would the above snippet run every 27 hours and 33 minutes, or every 27 hours starting at 33 minutes past the hour?
If this doesn't make it run every 27 hours and 33 minutes, what is the proper syntax for that?
It doesn't run, because cron supports these ranges:
minutes: 0-59
hours: 0-23
days of month: 1-31
months: 1-12 or Jan-Dec
days of week: 0-6 or Sun-Sat
27 for hours is not supported. Anyhow it doesn't exist the 27th hour in a 24-hours day.
The first field is minutes, so would run at 33 minutes past the hour.
But the next field is the hour field and it is set to run every 27th hour of the day, or in other words, never.
you misunderstand the /, it would mean when the number is dividable by that number, for example */2 would mean every 2 mins because every 2 mins the number is even and is able to be divided by 2.
When you want to create something specific you need to add it manually comma separated, like for example
33 27,54 * * * python /root/get_top.py

setting Cronjobs in exact time

i want to set a cronjob in directadmin control panel and i have a question. if i set a job in this format:
05 21 * * * /home/backup.sh
my script will run only one time in a day at 21:05 OR every 5 miutes(12 times in an hour) and every day at 21:00 ?? i want to my cronjobs run's only one time in a day at 21:05! please help me
Your script will run at 21:50 every day.
See the file formats manpage for crontab:
$ man 5 crontab
The line parts before the command for your crontab are: (Below is from the manpage.)
The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
A field may be an asterisk (*), which always stands for "first-last".
And you will see this example even further below: (Below is also from the manpage.)
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
man is your friend.
As per the cronjob set by you the first * means minutes, second * means Hour, third * means month, fourth * means day of the month and last * means day of the week. So if you set by
5 21 * * * it would run the job at 9:05pm minutes only.
For more about cronjob check http://www.thesitewizard.com/general/set-cron-job.shtml
Thanks & Regards,
Alok Thaker

How to skip saturday and sunday in a cron expression?

Hi I want to create a cron expression excluding saturday and sunday.
Begin the line with 0 0 * * 1,2,3,4,5 <user> <command>. The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days. monday to friday. 6=saturday 0=sunday.
Try this:
# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>

Resources