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