Controlling the time of anacron's cron.daily in raspbian buster?

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?

Thanks

Reply to
Adam Funk
Loading thread data ...

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?

Reply to
Roger Bell_West

On a sunny day (Sun, 16 Feb 2020 15:05:41 +0000) it happened Adam Funk wrote in :

Not sure your buster is same as my buster as I modify things from install time onwards, but as root in /root I edit: crtab

to make any changes, then run crontab crtab

In my crtab it says for daily:

#MIN HOUR DAY MONTH DAYOFWEEK COMMAND # Run daily cron jobs at 4:40 every day:

40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null

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.

Reply to
Jan Panteltje

Lol ;-)

--
There?s a mighty big difference between good, sound reasons and reasons  
that sound good. 

Burton Hillis (William Vaughn, American columnist)
Reply to
The Natural Philosopher

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
Reply to
Adam Funk

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.

Reply to
Anssi Saari

My pi's are in a box at the moment, but I would look in /etc/anacrontab as that seems to be relevant and has entries for cron.{daily|weekly|monthly}.

--
Consulting Minister for Consultants, DNRC 
I can please only one person per day. Today is not your day. Tomorrow 
isn't looking good, either. 
I am BOFH. Resistance is futile. Your network will be assimilated.
Reply to
I R A Darth Aggie

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.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

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
Reply to
Adam Funk

maybe you need to restart a daemon, or, for safety, reboot?

--
?People believe certain stories because everyone important tells them,  
and people tell those stories because everyone important believes them.  
Indeed, when a conventional wisdom is at its fullest strength, one?s  
agreement with that conventional wisdom becomes almost a litmus test of  
one?s suitability to be taken seriously.? 

Paul Krugman
Reply to
The Natural Philosopher

Good idea! I'll see what happens tomorrow morning.

--
But the government always tries to coax well-known writers into the 
Establishment; it makes them feel educated.        ---Robert Graves
Reply to
Adam Funk

If not yet fixed, I would suggest a read of:

formatting link

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.

MArtin

Reply to
notvail

You stopped reading too early:

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.

--
https://www.greenend.org.uk/rjk/
Reply to
Richard Kettlewell

Tried that yesterday --- ran at 07:30 again this morning. Thanks anyway!

--
Ambassador Trentino: "I am willing to do anything to prevent this 
  war." 
President Firefly: "It's too late. I've already paid a month's  
  rent on the battlefield."                          _Duck Soup_
Reply to
Adam Funk

Did anacron also run at 0530 and 0630?

Look at the "timestamp" files in /var/spool/anacron.

If the timestamp for cron.daily is 0730, then it will next run these at the next 0730. Possibly "touch" the timestamp files with 0530?

--

Chris Elvidge, England
Reply to
Chris Elvidge

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?

Reply to
Anssi Saari

...

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:

#OnCalendar=*-*-* 07..23:30 OnCalendar=*-*-* 05..23:30

Then I used touch to set the timestamp on /var/spool/anacron/cron.daily back a few hours.

And cron.daily got run at 07:30 again this morning. Any more suggestions? I'd be grateful.

--
But the government always tries to coax well-known writers into the 
Establishment; it makes them feel educated.        ---Robert Graves
Reply to
Adam Funk

^^^^^^^^^^

I have no idea why you would do that.

You will probably need to run ?systemctl daemon-reload?, but you?ll need to undo the random file deletion above first.

--
https://www.greenend.org.uk/rjk/
Reply to
Richard Kettlewell

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 
last man gets the credit and we forget the others.       ---Mark Twain
Reply to
Adam Funk

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.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

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.