Bonjour,
Basile Starynkevitch <
[email protected]> wrote on 17/11/2022 at 15:02:38+0100:
Bonjour la liste
A la maison comme au bureau (j'y suis actuellement au CEA LIST, et ssh
vers mon PC fixe du bureau à la maison) j'ai la chance d'avoir un
"gros" PC fixe sous Debian (au bureau) ou Ubuntu (chez moi).
Au bureau: Intel(R) Xeon(R) Silver 4114 CPU, Dell WS Precision 7920
avec 128Go de RAM. Aucun onduleur, et parfois des coupures de courant.
Disque SSD + Disque rotatif. J'ai parfois perdu une journée de boulot
par suite d'une coupure de courant.
Chez moi: une configuration assemblée par Materiel.net avec AMD Ryzen Threadripper 2970WX et 64Go de RAM. Disque SSD + disque rotatif.
J'ai codé en quelques heures (chez moi) l'utilitaire https://github.com/bstarynk/misc-basile/blob/master/sync-periodically.c
qui lance l'appel système sync(2) toutes les quelques secondes.
L'idée étant qu'en cas de coupure de courant, je ne perds pas trop de fichiers (étant dévelopeur, ça m'embêterais).
Au jugé, je pense que tu as inventé une roue qui est inutile.
Je m'explique : sync est une API vers le syscall sous-jacent (du même
nom) qui instruit au noyau de committer le cache des filesystems vers
les disques. Sous ext4 par exemple, cela consiste à démarrer un nouveau commit du journal.
Or, par défaut, un file system ext4 monté n'étant pas sur un plugdev est paramétré pour que de tels commits aient lieu toutes les cinq secondes.
Par ailleurs, un commit est automatiquement initié dès que le buffer
(cache) du noyau pour un filesystem est plein, ce qui sur un make ou
autre arrive très vite.
Bref, à première vue, ton programme ne me semble servir à rien d'autre
que ralentir ta machine en faisant des commits toutes les trois secondes
de façon non-optimale. Mais je peux avoir loupé quelque chose.
Je pense que juste passer commit=3 dans ton fstab et dropper ton service
serait plus pertinent.
Au bureau j'ai Debian/Sid (que je viens de [re]installer hier, par
mise à jour de Debian/Testing en Debian/Instable)
root@pcbasile:/# /lib/systemd/systemd --version
systemd 252 (252.1-1)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2
+IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD
-BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
-En italique violet, le prompt du shell-.
et le fichier /etc/systemd/system/sync-periodically.service contient
# on https:///github.com/bstarynk/misc-basile.git
# for Linux Debian/Buster systemd, encoded in UTF-8
# see https://wiki.debian.org/systemd/Services
# it should be installed as /etc/systemd/system/sync-periodically.service
# and then run systemctl enable sync-periodically.service
#
# © Copyright 2020 Basile Starynkevitch <[email protected]>
# (near Paris, France)
#
# This sync-periodically.service script is free software; you can
# redistribute it and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation; either
# version 2, or (at your option) any later version.
#
# this sync-periodically.service script is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
#
[Unit]
Description=a service to sync(2) periodially our disks on Debian
Documentation=See https:///github.com/bstarynk/misc-basile.git files sync-periodically.{c,service}
After=network.target sshd.service
ConditionPathExists=!/etc/local/sync-periodically-dont-run
[Service]
ExecStartPre=/bin/bash -c "[ -x /usr/local/bin/sync-periodically ]"
ExecStart=/usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid --sync-period=3 --log-period=300
ExecReload=/usr/bin/ldd /usr/local/bin/sync-periodically
RestartSec= 500ms
Restart=on-failure
RestartPreventExitStatus=254
Type=notify
KillMode=process
RuntimeDirectory=/var/run
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sync-periodically.service
et pour une raison incompréhensible de moi (je connais mal systemd) il y a quatre processus sync-periodically
root@pcbasile:/# ps auxw|egrep 'USER|sync-'
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 3157 0.0 0.0 2460 92 ? Ss 12:43 0:01 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=300
root 3160 0.0 0.0 2460 96 ? Ss 12:43 0:01 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=300
root 3164 0.0 0.0 2460 96 ? Ss 12:43 0:01 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=300
root 3167 0.0 0.0 2460 92 ? Ss 12:43 0:00 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=300
root 3170 0.0 0.0 2460 96 ? Ss 12:43 0:01 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=300
root 55537 0.0 0.0 6464 2200 pts/3 S+ 14:57 0:00 grep -E USER|sync-
-------------------------------------------------------------------------------------------------------------------------
A la maison j'ai Ubuntu 22 (je vais peut-être installer Debian dans quelques jours)
rimski % /lib/systemd/systemd --version
systemd 251 (251.4-1ubuntu7)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2
+IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD
-BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
avec comme fichier /etc/systemd/system/sync-periodically.service qui contient
# fichier /etc/systemd/system/sync-periodically.service
[Unit]
Description=a service to sync(2) periodially our disks on Debian Documentation=See https:///github.com/bstarynk/misc-basile.git files sync-periodically.{c,service}
After=network.target sshd.service ConditionPathExists=!/etc/local/sync-periodically-dont-run
[Service]
ExecStartPre=/bin/bash -c "[ -x /usr/local/bin/sync-periodically ]" ExecStart=/usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid --sync-period=3 --log-period=300
ExecReload=/usr/bin/ldd /usr/local/bin/sync-periodically
RestartSec= 500ms
Restart=on-failure
RestartPreventExitStatus=254
Type=notify
KillMode=process
RuntimeDirectory=/var/run
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sync-periodically.service
mais un seul processus avec ps auxw|egrep 'USER|sync-':
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND systemd+ 1549 0.0 0.0 89644 6640 ? Ssl 08:25 0:00 /lib/systemd/systemd-timesyncd
root 48926 0.0 0.0 2624 96 ? Ss 08:34 0:07 /usr/local/bin/sync-periodically --daemon --pid-file=/var/run/sync-periodically.pid
--sync-period=3 --log-period=600
basilest 1820495 0.0 0.0 9060 2292 pts/5 S+ 15:00 0:00 grep -E USER|sync
Où est mon erreur, ou pourquoi une telle différence?
Sur la machine où tu as 4 instances, peux-tu fournir le résultat des commandes "systemctl status sync-periodically.service" ? Idem avec
"journalctl -u sync-periodically.service".
Un "ps auxf" ne serait pas de refus non plus.
Bien à toi,
--
PEB
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)