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

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-16, Adam Funk wrote:
Quoted text here. Click to load it

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?

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 16/02/2020 15:16, Roger Bell_West wrote:
Quoted text here. Click to load it
Lol ;-)


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

We've slightly trimmed the long signature. Click to see the full one.
Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-16, Roger Bell_West wrote:

Quoted text here. Click to load it

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

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

Quoted text here. Click to load it

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.

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On Sun, 16 Feb 2020 15:16:09 +0000, Roger Bell_West wrote:

Quoted text here. Click to load it

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


Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-18, Martin Gregorie wrote:

Quoted text here. Click to load it

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

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 19/02/2020 16:04, Adam Funk wrote:
Quoted text here. Click to load it
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.  
We've slightly trimmed the long signature. Click to see the full one.
Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-19, The Natural Philosopher wrote:

Quoted text here. Click to load it

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

Re: Controlling the time of anacron's cron.daily in raspbian buster?
If not yet fixed, I would suggest a read of:
http://manpages.ubuntu.com/manpages/bionic/man7/systemd.cron.7.html

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


wrote:
<snip>

Quoted text here. Click to load it

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-19, The Natural Philosopher wrote:

Quoted text here. Click to load it

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


--  
Ambassador Trentino: "I am willing to do anything to prevent this
  war."
We've slightly trimmed the long signature. Click to see the full one.
Re: Controlling the time of anacron's cron.daily in raspbian buster?
Quoted text here. Click to load it

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/

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

Quoted text here. Click to load it

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?

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-20, Richard Kettlewell wrote:

Quoted text here. Click to load it
...

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

Re: Controlling the time of anacron's cron.daily in raspbian buster?
Quoted text here. Click to load it
                                     ^^^^^^^^^^

I have no idea why you would do that.

Quoted text here. Click to load it

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/

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-24, Richard Kettlewell wrote:

Quoted text here. Click to load it

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/...?


Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: Controlling the time of anacron's cron.daily in raspbian buster?
On Mon, 24 Feb 2020 13:54:29 +0000, Adam Funk wrote:

Quoted text here. Click to load it
There's a fairly decent description of systemd, how it works and is  
configured here:

https://www.freedesktop.org/wiki/Software/systemd/

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


Re: Controlling the time of anacron's cron.daily in raspbian buster?
On Mon, 24 Feb 2020 14:36:56 +0000, Martin Gregorie wrote:

Quoted text here. Click to load it

Dang it, I was hoping for something wonderful for keeping customization.
What I found was

  Q: I want to change a service file, but rpm keeps overwriting it
  in /usr/lib/systemd/system all the time, how should I handle this?

  A: The recommended way is to copy the service file from
  /usr/lib/systemd/system to /etc/systemd/system and edit it there. The
  latter directory takes precedence over the former, and rpm will
  never overwrite it. If you want to use the distributed service
  file again you can simply delete (or rename) the service file in
  /etc/systemd/system again.

Which sounds like the road the OP went down initially. I always want to
use the service file that comes with the latest software so everything's
compatible & works as designed. I just want to tweak one setting in there,
PrivateTmp to be specific.

Right now I have a little script that runs right after updates and
checks the setting and edits the service file with sed as needed then
runs systemctl daemon-reload;systemctl restart THE_SERVICE

I guess I'm stuck with that... Unless someone knows of deeper magic
they're willing to share?

Re: Controlling the time of anacron's cron.daily in raspbian buster?
On Tue, 25 Feb 2020 15:21:51 +0000, Joe Beanfish wrote:

Quoted text here. Click to load it

Yes, but not, AFAIK usable with Raspbian. The Fedora distro's dnf package  
manager is capable of updating config files without overwriting any  
customisations you may have previously applied, and this applies to  
systemd gubbins as well. If for some reason it has to clobber a custom  
setting, it flops the new file in after making a copy of the one it  
replaces.  

Its dead easy to find these cases - just run "locate *.rpmnew" after  
running "dnf update". and then using diff and your favourite editor to  
reconcile the two. Can't think why Debian doesn't do something similar.


--  
Martin    | martin at
Gregorie  | gregorie dot org


Re: Controlling the time of anacron's cron.daily in raspbian buster?
On 2020-02-25, Martin Gregorie wrote:
Quoted text here. Click to load it

Er, that's just what Debian does: gives you a choice of which file to
have active, old or new, and leaves the other one available for
inspection. (*.dpkg-old, *.dpkg-dist in this case.)

If you want to combine a custom setting with always using the latest
supplied config for the rest of the file, you need something a little
more sophisticated than that. Manual editing, or something automated
like Puppet or Ansible.

Site Timeline