View previous topic :: View next topic |
Author |
Message |
Robert S Guru
Joined: 15 Aug 2004 Posts: 462 Location: Canberra Australia
|
Posted: Sat Jun 08, 2024 12:35 am Post subject: How to get cron.weekly/monthly to run on day of week/month? |
|
|
My cron.weekly jobs prevoiusly ran on Saturdays, which was the most convenient day for me. Now they run on Sundays for some unknown reason. Similarly, my monthly cron jobs seem to run near the end of the month, not at the start, as desired. I'm using pretty much the default configuration of cronie.
I'd like my weekly jobs to run on Saturday, and monthly jobs to run on the first day. How to I configure this? It used to be easy with vixie-cron using /etc/crontab. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3438
|
Posted: Sat Jun 08, 2024 6:56 am Post subject: |
|
|
/etc/cron.d/dailyjobs might contain the answer.
Anyway, cron and anacron work in different ways:
cron triggers jobs exactly _on_ the specified _time_, and anacron triggers jobs _after_ the specified _delay_. If you want your jobs to run on a specific day of a month, put them in as crontab jobs with a trigger time and not as anacron jobs running on interval. _________________ Make Computing Fun Again |
|
Back to top |
|
|
Robert S Guru
Joined: 15 Aug 2004 Posts: 462 Location: Canberra Australia
|
Posted: Sat Jun 08, 2024 9:03 am Post subject: |
|
|
Thanks. Just checking:
Quote: | # cat /etc/cron.d/0daily
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
5 2 * * * root cd / && run-parts --report /etc/cron.daily
47 4 * * 7 root cd / && run-parts --report /etc/cron.weekly
52 6 1 * * root cd / && run-parts --report /etc/cron.monthly
|
Quote: | cat /etc/anacrontab
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
RANDOM_DELAY=45
START_HOURS_RANGE=3-22
|
|
|
Back to top |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1029 Location: Somewhere in Denmark
|
Posted: Sat Jun 08, 2024 12:58 pm Post subject: |
|
|
Robert S wrote: | Thanks. Just checking:
Quote: | # cat /etc/cron.d/0daily
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
5 2 * * * root cd / && run-parts --report /etc/cron.daily
47 4 * * 7 root cd / && run-parts --report /etc/cron.weekly
52 6 1 * * root cd / && run-parts --report /etc/cron.monthly
|
Quote: | cat /etc/anacrontab
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
RANDOM_DELAY=45
START_HOURS_RANGE=3-22
|
|
Code: | # For details see man 5 crontab
# 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 |
You weekly jobs are set to run on sunday so that matches your findings, your monthly jobs are set to run on day 1 of month.
I don't really know anacron - but going from the config it seems to say to only start jobs between 3 and 22 and with a random delay of 45 minutes - ie. you hourly jobs will not start at 02:05 but at 3:00 (dunno if the delay is added to that or to the 2:05 requested in dailyjobs?) - I would guess |
|
Back to top |
|
|
|