Bug#956953: cron: add cron jobs to systemd scope cgroups

2024-06-08 Thread Georges Khaznadar
Hello Paul,

I am still missing a feedback about cron 3.0pl1-190

If you are still interested in having the new feature some day in
debian/testing (and later in debian/stable), I would appreciate to get
a ping, even if you are currently too busy to make tests.

Thank you in advance,   Georges.

On Thu, 23 May 2024 14:26:23 +0200 Georges Khaznadar 
 wrote:
> I uploaded a new cron release (3.0pl1-190) to experimental.
> 
> Please can you test this release?
> ... 


signature.asc
Description: PGP signature


Bug#956953: cron: add cron jobs to systemd scope cgroups

2024-05-23 Thread Georges Khaznadar
Hello Paul,

I uploaded a new cron release (3.0pl1-190) to experimental.

Please can you test this release?

If the modifications match your needs, would you be kind enough to
propose two additional things?

1- a script to test that the new feature is working (when cron is
   installed in a clean chroot)

2- a short description of Debian's specific feature which is added by
   the new release, to be included at some point in cron's man page.

Thank you in advance for your feedback.

Best regards,   Georges.

Paul Wise a écrit :
> On Mon, 2023-12-18 at 16:07 +0100, Georges Khaznadar wrote:
> 
> > Can I assume that you are talking about the switch --description= ?
> 
> I was talking about --unit but as long as the resulting unit name bears
> some resemblance to the cron command it is from, that would be fine.
> 
> > I would propose to use the command's name (without arguments), appended
> > with an underscore and the pid of the forked grandchild process managed
> > by cron as a description. So one can take a look at /proc/ to get
> > more information. What do you think about it?
> 
> Hmm, for the description I would just use the full command with args,
> prepended with "cron job $USER $PID: " or something similiar.
> 
> -- 
> bye,
> pabs
> 
> https://wiki.debian.org/PaulWise



-- 
Georges KHAZNADAR et Jocelyne FOURNIER
22 rue des mouettes, 59240 Dunkerque France.
Téléphone +33 (0)3 28 29 17 70



signature.asc
Description: PGP signature


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-20 Thread Paul Wise
On Mon, 2023-12-18 at 16:07 +0100, Georges Khaznadar wrote:

> Can I assume that you are talking about the switch --description= ?

I was talking about --unit but as long as the resulting unit name bears
some resemblance to the cron command it is from, that would be fine.

> I would propose to use the command's name (without arguments), appended
> with an underscore and the pid of the forked grandchild process managed
> by cron as a description. So one can take a look at /proc/ to get
> more information. What do you think about it?

Hmm, for the description I would just use the full command with args,
prepended with "cron job $USER $PID: " or something similiar.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise


signature.asc
Description: This is a digitally signed message part


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-18 Thread Georges Khaznadar
Hello Paul,

Paul Wise a écrit :
> On Sun, 2023-12-17 at 16:28 +0100, Georges Khaznadar wrote:
> 
> > So maybe prepending "systemd-run --scope --user" would do the trick,
> > wouldn't it?
> 
> I think that would work yes. Please set an appropriate name too though.

Can I assume that you are talking about the switch --description= ?
As stated in the man page, "If not specified, the command itself will be
used as a description."

By the way, if I run 
`systemd-run --scope --user --description='some  weird s|ri\ng' some\ 
command`,
is systemd-run self-protected, does it sanitize such an input? If not,
we should first ask systemd-run's authors to improve it, don't we?

I would propose to use the command's name (without arguments), appended
with an underscore and the pid of the forked grandchild process managed
by cron as a description. So one can take a look at /proc/ to get
more information. What do you think about it?

Best regards,   Georges.



signature.asc
Description: PGP signature


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-17 Thread Paul Wise
On Sun, 2023-12-17 at 16:28 +0100, Georges Khaznadar wrote:

> So maybe prepending "systemd-run --scope --user" would do the trick,
> wouldn't it?

I think that would work yes. Please set an appropriate name too though.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise


signature.asc
Description: This is a digitally signed message part


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-17 Thread Georges Khaznadar
Hello Paul,

Paul Wise a écrit :
> > I presume that one way to implement your wished feature might be to
> > modify beforehand the string e->cmd, in order to insert something as
> > "systemd-run --scope" at the begin...
> 
> I note that this requires user authentication even when run as a user
> so presumably it would not work in cron itself.

So maybe prepending "systemd-run --scope --user" would do the trick,
wouldn't it?

Best regards,   Georges.



signature.asc
Description: PGP signature


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-16 Thread Paul Wise
On Sat, 2023-12-16 at 16:19 +0100, Georges Khaznadar wrote:

> as I am not experienced with cgroups, I would appreciate some help if you
> have got time to offer it.

Me either TBH, so the systemd team might be better to ask about this.

> I presume that one way to implement your wished feature might be to
> modify beforehand the string e->cmd, in order to insert something as
> "systemd-run --scope" at the begin...

I note that this requires user authentication even when run as a user
so presumably it would not work in cron itself.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise


signature.asc
Description: This is a digitally signed message part


Bug#956953: cron: add cron jobs to systemd scope cgroups

2023-12-16 Thread Georges Khaznadar
Hello Paul,

as I am not experienced with cgroups, I would appreciate some help if you
have got time to offer it.

Here is the code authored by Vixie to launch a cron job, as a grandchild
of cron's main process:
-8<---
execle(shell, shell, "-c", e->cmd, (char *)0, e->envp);
-8<---

I presume that one way to implement your wished feature might be to
modify beforehand the string e->cmd, in order to insert something as
"systemd-run --scope" at the begin...


What do you think about it ?

Thank you in advance for any hint.

Best regards,   Georges.

Paul Wise a écrit :
> Package: cron
> Severity: wishlist
> 
> It would be nice to have cron add the jobs it creates to systemd scope
> cgroups. The groups could be named according to the source of the job
> and the content of the cron job with unsafe characters replaced.
> 
> crontab-root-17-*-*-*-*-cd-run-parts-report-etc-cron-hourly.scope
> user-root-0-0-*-*-*-mysqlbackup.scope
> user-pabs-0-7-*-*-*-sm-go-to-work.scope
> 
> This would make it easier to see at a glance which processes belong to
> which cron job, right now the only way to do this is to set environment
> variables distinguishing the cron jobs and then grep the environment
> variables of process in the cron.service group.
> 
> $ < /sys/fs/cgroup/systemd/system.slice/cron.service/cgroup.procs xargs 
> -d'\n' -n1 -I^ grep -lz PABS_CRON_JOB= /proc/^/environ 2> /dev/null | grep -o 
> '[0-9]\+'
> 20586
> 20587
> 20589
> 20594
> 20600
> $ systemctl status cron.service
> ● cron.service - Regular background program processing daemon
>  Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor 
> preset: enabled)
>  Active: active (running) since Fri 2020-04-17 10:40:25 AWST; 4h 53min ago
>Docs: man:cron(8)
>Main PID: 907 (cron)
>   Tasks: 11 (limit: 14310)
>  Memory: 84.1M
>  CGroup: /system.slice/cron.service
>  ├─  907 /usr/sbin/cron -f
>  ├─20586 dbus-launch --autolaunch 
> 6b1b8c9f8021eeb6f685a77d48917a8a --binary-syntax --close-stderr
>  ├─20587 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 
> --print-address 7 --session
>  ├─20589 /usr/libexec/at-spi-bus-launcher
>  ├─20594 /usr/bin/dbus-daemon 
> --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork 
> --print-address 3
>  └─20600 /usr/libexec/at-spi2-registryd --use-gnome-session
> 
> -- 
> bye,
> pabs
> 
> https://wiki.debian.org/PaulWise



-- 
Georges KHAZNADAR et Jocelyne FOURNIER
22 rue des mouettes, 59240 Dunkerque France.
Téléphone +33 (0)3 28 29 17 70



signature.asc
Description: PGP signature


Bug#956953: cron: add cron jobs to systemd scope cgroups

2020-04-17 Thread Paul Wise
Package: cron
Severity: wishlist

It would be nice to have cron add the jobs it creates to systemd scope
cgroups. The groups could be named according to the source of the job
and the content of the cron job with unsafe characters replaced.

crontab-root-17-*-*-*-*-cd-run-parts-report-etc-cron-hourly.scope
user-root-0-0-*-*-*-mysqlbackup.scope
user-pabs-0-7-*-*-*-sm-go-to-work.scope

This would make it easier to see at a glance which processes belong to
which cron job, right now the only way to do this is to set environment
variables distinguishing the cron jobs and then grep the environment
variables of process in the cron.service group.

$ < /sys/fs/cgroup/systemd/system.slice/cron.service/cgroup.procs xargs -d'\n' 
-n1 -I^ grep -lz PABS_CRON_JOB= /proc/^/environ 2> /dev/null | grep -o '[0-9]\+'
20586
20587
20589
20594
20600
$ systemctl status cron.service
● cron.service - Regular background program processing daemon
 Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: 
enabled)
 Active: active (running) since Fri 2020-04-17 10:40:25 AWST; 4h 53min ago
   Docs: man:cron(8)
   Main PID: 907 (cron)
  Tasks: 11 (limit: 14310)
 Memory: 84.1M
 CGroup: /system.slice/cron.service
 ├─  907 /usr/sbin/cron -f
 ├─20586 dbus-launch --autolaunch 6b1b8c9f8021eeb6f685a77d48917a8a 
--binary-syntax --close-stderr
 ├─20587 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 
--print-address 7 --session
 ├─20589 /usr/libexec/at-spi-bus-launcher
 ├─20594 /usr/bin/dbus-daemon 
--config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork 
--print-address 3
 └─20600 /usr/libexec/at-spi2-registryd --use-gnome-session

-- 
bye,
pabs

https://wiki.debian.org/PaulWise


signature.asc
Description: This is a digitally signed message part