I have a cron job that runs once a day. But I would like to make it run at midnight or other time exactly.
The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM. Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.
Thankfully, you can configure a specific timezone for your Cron job as follows: First, you need to export the TZ variable in your Shell script before any other Shell entries. Next, access your crontab and use the crontab environment variable CRON_TZ at the start of the crontab file.
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
Yes, it is perfectly acceptable to have cron schedule multiple jobs at the same time. Computers do nothing simultaneously, however, and they will be started in the order present in the cron table.
You can also specify the exact values for each gr
0 2,10,12,14,16,18,20 * * *
It stands for 2h00, 10h00, 12h00 and so on, till 20h00.
From the above answer, we have:
The comma, ",", means "and". If you are confused by the above line, remember that spaces are the field separators, not commas.
And from (Wikipedia page):
* * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59)
Hope it helps :)
--
EDIT:
check out
http://www.thesitewizard.com/general/set-cron-job.shtml
for the specifics of setting your crontab directives.
45 10 * * *
will run in the 10th hour, 45th minute of every day.
for midnight... maybe
0 0 * * *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With