I want the cron.daiy jobs to run earlier in the morning than they do by default. I used to do this by editing the time in /etc/cron.d/anacron, but that no longer works; nor does changing the time in the cron.daily line of /etc/crontab. How is this controlled now?
Welcome to the systemd snake pit. There will be an undocumented command somewhere to change it, but why would you want to override systemd's defaults, which are perfect for every computer and every usage pattern?
So changing 40 4 * ** to say 40 3 ** * should run daily stuff at 3 o'clock.
Again I copied crtab from my other systems so maybe it is different on your system.
Finally run crontab -l to see if you made any typos.
In my crtab there are now many enries for things that need happening at different times, thing is on 24/7 AFAIK this has been the Unix way for many decennia.
Ha! In all fairness, I haven't had any other trouble from the switch to systemd (with Raspbian on the Pi or Ubuntu on other machines), and it was used in stretch.
--
You cannot really appreciate Dilbert unless you've read it in the
original Klingon. ---Klingon Programmer's Guide
I guess things have changed in Buster for cron, I have Stretch on my Pi and there systemd's cron.service just starts /usr/sbin/cron and changes to /etc/crontab do affect cron.
Look at "man 8 cron" to see how crond is run, including under systemd. These days crond only handles the jobs that run more frequently than daily as well as those with their own run schedule, i.e those the run several times a day or to a more complex run schedule. It also has useful references to other manpages.
For jobs that run daily, weekly or monthly, see at "man 8 anacron" for details of the controlling daemon, anacron, and "man anacrontab" to see how to configure anacron, including changing the time of day these jobs will be run at.
I can't find anything there on how to change the start time each day; man 8 anacron does say this:
DEBIAN-SPECIFIC CONFIGURATION On Debian-based systems, anacron will be activated hourly every day from 07:30 local time to 23:30 local time through cron job (on non-systemd systems where cron is installed and enabled) or systemd timer (on systemd-based systems). On activation, anacron will check if it missed some jobs. If yes, it will start those jobs after a short period of time.
But I don't see how to change the 07:30 start. I made the following change in /etc/cron.d/anacron yesterday
#30 7-23 * * * root [ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi
30 5-23 * * * root [ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi
but it still ran at 07:30.
--
Well, in this world of basic stereotyping, give a guy a big nose and
some weird hair and he is capable of anything. ---Frank Zappa
Yes I know its not pi specific but both raspbian and ubuntu are systemd based and that page seems to give some decent info on how the systemd timers work.
FILES /etc/anacrontab Contains specifications of jobs. See anacrontab(5) for a com? plete description.
/var/spool/anacron This directory is used by Anacron for storing timestamp files.
/lib/systemd/system/anacron.service This file provides systemd service for anacron.
/lib/systemd/system/anacron.timer This file provides systemd timer for anacron. Currently the ser? vice is triggered hourly through systemd timer.
Start with ?man systemd.timer? for the syntax & meaning of the timer file, and look for ?Overriding vendor settings? in ?man systemd.unit? for how to modify its behavior.
Thank you. This was driving me nuts as I don't currently have access to a Buster system with Anacron installed... But still there's also the script that was posted here:
30 5-23 * * * root [ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi
Which explicitly checks for systemd and doesn't do anything if detected. Should give a hint on why modifying that script doesn't help much, no?
Thanks --- I think I'm getting closer, but not successful yet. I found a symlink from /etc/systemd/system/timers.target.wants/anacron.timer to /lib/systemd/system/anacron.timer, deleted it, copied the linked file into the etc location, and edited the relevant-looking line as follows:
Some stuff in the documentation led to believe that customized files should go straight in etc --- should I restore the symlink and edit the file in /lib/systemd/...?
Good point (I know I restarted cron and anacron, but forgot to mention that above).
--
It takes a thousand men to invent a telegraph, or a steam engine, or a
phonograph, or a telephone or any other important thing --- and the
There's a fairly decent description of systemd, how it works and is configured here:
formatting link
IIRC it has instructions for changing configured values: it describes a way of storing changes to standard settings so that future system updates won't clobber your site-specific change.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.