Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.bugs.dist > #1125188 > unrolled thread

Bug#923014: Add systemd unit - allow usage without cron installed

Started byBill Allombert <ballombe@debian.org>
First post2022-11-16 19:30 +0100
Last post2022-11-20 01:20 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.debian.bugs.dist

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Bug#923014: Add systemd unit - allow usage without cron installed Bill Allombert <ballombe@debian.org> - 2022-11-16 19:30 +0100
    Bug#923014: Add systemd unit - allow usage without cron installed Paul Wise <pabs@debian.org> - 2022-11-17 02:40 +0100
      Bug#923014: Add systemd unit - allow usage without cron installed Alexandre Detiste <alexandre.detiste@gmail.com> - 2022-11-17 05:30 +0100
      Bug#923014: Add systemd unit - allow usage without cron installed Bill Allombert <ballombe@debian.org> - 2022-11-18 16:10 +0100
        Bug#923014: Add systemd unit - allow usage without cron installed Paul Wise <pabs@debian.org> - 2022-11-19 10:30 +0100
        Bug#923014: Add systemd unit - allow usage without cron installed Paul Wise <pabs@debian.org> - 2022-11-20 01:20 +0100

#1125188 — Bug#923014: Add systemd unit - allow usage without cron installed

FromBill Allombert <ballombe@debian.org>
Date2022-11-16 19:30 +0100
SubjectBug#923014: Add systemd unit - allow usage without cron installed
Message-ID<FsvkB-4aTc-3@gated-at.bofh.it>
On Fri, Feb 22, 2019 at 04:00:30PM -0800, Bryan Quigley wrote:
> Package: popularity-contest
> Version: 1.67
> 
> This is regards to the popularity-contest cron job.  I'm looking into
> running systems without anacron/cron installed - instead using systemd
> timers.

Hello Bryan,

Why not use systemd-cron instead ?

/etc/cron.daily/popularity-contest is a conffile, I cannot make it into
a systemd service.

Sorry for not answering sooner, systemd is still mysterious to me.

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 

[toc] | [next] | [standalone]


#1125244

FromPaul Wise <pabs@debian.org>
Date2022-11-17 02:40 +0100
Message-ID<FsC2J-4f0P-1@gated-at.bofh.it>
In reply to#1125188

[Multipart message — attachments visible in raw view] — view raw

On Wed, 2022-11-16 at 19:00 +0100, Bill Allombert wrote:

> /etc/cron.daily/popularity-contest is a conffile, I cannot make it into
> a systemd service.

The usual way to handle both cron and systemd timers is to move most of
the logic in the cron script into a script in /usr then make the cron
script exit under systemd or call the /usr script under sysvinit and
then add a systemd timer and service that calls the /usr script.

An example of this approach is in the apt package, I think you could
use most of that as-is but adjusting names for the popcon cron job:

   /etc/cron.daily/apt-compat
   /usr/lib/apt/apt.systemd.daily
   /lib/systemd/system/apt-daily.service
   /lib/systemd/system/apt-daily.timer
   /lib/systemd/system/apt-daily-upgrade.service
   /lib/systemd/system/apt-daily-upgrade.timer
   
The systemd.directives manual page can be used to look up where
individual settings in the systemd service/timer files are documented.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

[toc] | [prev] | [next] | [standalone]


#1125253

FromAlexandre Detiste <alexandre.detiste@gmail.com>
Date2022-11-17 05:30 +0100
Message-ID<FsEHf-4gS8-3@gated-at.bofh.it>
In reply to#1125244

[Multipart message — attachments visible in raw view] — view raw

Hi,

That's nucely written out, better than I could.

An extra bit of policy(*) I attempt to infuse with/for systemd-cron is this
one: the name of the crontab (here "apt-compat")
should match the name of the main timer (here "apt-daily", so not the case
yet) so that systemd-cron will ignore this one crontab and won't generate a
dynamic .timer + .service in /run for this package.

So my end goal for systemd-cron is that it would do nothing i.e. generate
no dynamic .timer / .service pair because all crontab would have a matching
static .timer shipped in the same package.

I understand it's a bit convulated to wrap it's mind around this one.

(*): not yet proposed for Policy, already talked about here:
https://lists.debian.org/debian-devel/2022/03/msg00211.html

Greetings,

Le jeu. 17 nov. 2022, 02:39, Paul Wise <pabs@debian.org> a écrit :

>
>    /etc/cron.daily/apt-compat
>    /usr/lib/apt/apt.systemd.daily
>    /lib/systemd/system/apt-daily.service
>    /lib/systemd/system/apt-daily.timer
>    /lib/systemd/system/apt-daily-upgrade.service
>    /lib/systemd/system/apt-daily-upgrade.timer
>
>

[toc] | [prev] | [next] | [standalone]


#1125436

FromBill Allombert <ballombe@debian.org>
Date2022-11-18 16:10 +0100
Message-ID<Ftba9-4C1i-1@gated-at.bofh.it>
In reply to#1125244
On Thu, Nov 17, 2022 at 09:37:27AM +0800, Paul Wise wrote:

> On Wed, 2022-11-16 at 19:00 +0100, Bill Allombert wrote:
> 
> > /etc/cron.daily/popularity-contest is a conffile, I cannot make it into
> > a systemd service.
> 
> The usual way to handle both cron and systemd timers is to move most of
> the logic in the cron script into a script in /usr then make the cron
> script exit under systemd or call the /usr script under sysvinit and
> then add a systemd timer and service that calls the /usr script.

But then the user would not be able to configure it anymore,
so I do not see the upside.

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 

[toc] | [prev] | [next] | [standalone]


#1125521

FromPaul Wise <pabs@debian.org>
Date2022-11-19 10:30 +0100
Message-ID<FtskF-4N4N-15@gated-at.bofh.it>
In reply to#1125436

[Multipart message — attachments visible in raw view] — view raw

On Fri, 2022-11-18 at 16:06 +0100, Bill Allombert wrote:

> But then the user would not be able to configure it anymore,
> so I do not see the upside.

They would be able to configure it via the config file as usual.

   /etc/popularity-contest.conf

They could also patch it automatically via an apt hook if needed, but
most people won't need to do that, I will though so that I can modify
the report in unsupported ways, for eg filtering out certain packages.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

[toc] | [prev] | [next] | [standalone]


#1125624

FromPaul Wise <pabs@debian.org>
Date2022-11-20 01:20 +0100
Message-ID<FtGdY-4VNF-9@gated-at.bofh.it>
In reply to#1125436

[Multipart message — attachments visible in raw view] — view raw

On Fri, 2022-11-18 at 16:06 +0100, Bill Allombert wrote:

> But then the user would not be able to configure it anymore,
> so I do not see the upside.

I just discovered an alternative that preserves the current location
and the conffile status of the cron.daily script. The script stays the
same, except it exits under systemd when the first argument isn't a
option indicating that the script should continue under systemd.
The systemd service then passes that option as the only parameter.

An example from the exim4-base package:

   $ head -n8 /etc/cron.daily/exim4-base
   #!/bin/sh
   
   EX4SYSTEMDTIMER=$1
   
   # skip in favour of systemd timer if called from cron.daily
   if [ -d /run/systemd/system ] && [ "$EX4SYSTEMDTIMER" != "systemd-timer" ]; then
               exit 0
   fi
   
   $ systemctl cat exim4-base.service exim4-base.timer
   # /lib/systemd/system/exim4-base.service
   [Unit]
   Description=exim4-base housekeeping
   Documentation=man:exim4(8)
   ConditionACPower=true
   Before=logrotate.service
   
   [Service]
   Type=oneshot
   ExecStart=/etc/cron.daily/exim4-base systemd-timer
   
   # performance options
   Nice=19
   IOSchedulingClass=best-effort
   IOSchedulingPriority=7
   
   # /lib/systemd/system/exim4-base.timer
   [Unit]
   Description=Daily exim4-base housekeeping
   Documentation=man:exim4(8)
   Before=logrotate.timer
   
   [Timer]
   OnCalendar=daily
   AccuracySec=12h
   Persistent=true
   
   [Install]
   WantedBy=timers.target

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.bugs.dist


csiph-web