• =?UTF-8?Q?pourquoi_systemd_d=c3=a9marre_4_fois_le_m=c3=aame_service?= =

    From Basile Starynkevitch@21:1/5 to All on Thu Nov 17 15:20:02 2022
    This is a multi-part message in MIME format.
    Bonjour la liste


    A la maison comme au bureau (j'y suis actuellement au CEA LIST <https://list.cea.fr/>, 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 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 <basile@starynkevitch.net>
    # (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?


    Je serais même disposé à faire un paquet Debian, si ça pourrait être
    utile à d'autres.



    Merci

    --
    Basile Starynkevitch<basile@starynkevitch.net>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/

    <html>
    <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <p>Bonjour la liste</p>
    <p><br>
    </p>
    <p>A la maison comme au bureau (j'y suis actuellement au <a
    moz-do-not-send="true" href="https://list.cea.fr/">CEA LIST</a>,
    et <font face="monospace">ssh</font> 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).</p>
    <p><br>
    </p>
    <p>Au bureau: Intel(R) Xeon(R) Silver 4114 CPU, Dell WS Precision
    7920 avec 128Go de RAM. <i>Aucun onduleur</i>, 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.<br>
    </p>
    <p>Chez moi: une configuration assemblée par Materiel.net avec AMD
    Ryzen Threadripper 2970WX et 64Go de RAM. Disque SSD + disque
    rotatif.</p>
    <p>J'ai codé en quelques heures (chez moi) l'utilitaire <a
    moz-do-not-send="true" href="https://github.com/bstarynk/misc-basile/blob/master/sync-periodically.c"
    class="moz-txt-link-freetext">https://github.com/bstarynk/misc-basile/blob/master/sync-periodically.c</a>
    qui lance l'appel système <font face="Courier New, Courier,
    monospace">sync(2)</font> toutes les quelques secondes.</p>
    <p>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).</p>
    <p>Au bureau j'ai Debian/Sid (que je viens de [re]installer hier,
    par mise à jour de Debian/Testing en Debian/Instable)</p>
    <p><font face="Courier New, Courier, monospace"><font color="purple"><i>root@pcbasile:/#</i></font>
    /lib/systemd/systemd --version<br>
    systemd 252 (252.1-1)<br>
    +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</font></p>
    -En italique violet, le prompt du shell-.<br>
    <p>et le fichier  <font face="monospace">/etc/systemd/system/sync-periodically.service</font>
    contient<br>
    </p>
    <p>
    <blockquote type="cite"><font face="monospace"><br>
    # on <a class="moz-txt-link-freetext" href="https:///github.com/bstarynk/misc-basile.git">https:///github.com/bstarynk/misc-basile.git</a><br>
    # for Linux Debian/Buster systemd, encoded in UTF-8<br>
    # see <a class="moz-txt-link-freetext" href="https://wiki.debian.org/systemd/Services">https://wiki.debian.org/systemd/Services</a><br>
    # it should be installed as
    /etc/systemd/system/sync-periodically.service<br>
    # and then run systemctl enable sync-periodically.service<br>
    #<br>
    # © Copyright 2020 Basile Starynkevitch   
    <a class="moz-txt-link-rfc2396E" href="mailto:basile@starynkevitch.net">&lt;basile@starynkevitch.net&gt;</a><br>
    # (near Paris, France)<br>
    #<br>
    # This sync-periodically.service script is free software; you
    can<br>
    # redistribute it and/or modify it under the terms of the GNU
    General<br>
    # Public License as published by the Free Software Foundation;
    either<br>
    # version 2, or (at your option) any later version.<br>
    #<br>
    # this sync-periodically.service script is distributed in the
    hope that<br>
    # it will be useful, but WITHOUT ANY WARRANTY; without even
    the implied<br>
    # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    PURPOSE.  See<br>
    # the GNU General Public License for more details.<br>
    #<br>
    <br>
    [Unit]<br>
    Description=a service to sync(2) periodially our disks on
    Debian<br>
    Documentation=See <a class="moz-txt-link-freetext" href="https:///github.com/bstarynk/misc-basile.git">https:///github.com/bstarynk/misc-basile.git</a>
    files sync-periodically.{c,service}<br>
    After=network.target sshd.service<br>
    ConditionPathExists=!/etc/local/sync-periodically-dont-run<br>
    <br>
    [Service]<br>
    ExecStartPre=/bin/bash -c "[ -x
    /usr/local/bin/sync-periodically ]"<br>
    ExecStart=/usr/local/bin/sync-periodically --daemon
    --pid-file=/var/run/sync-periodically.pid --sync-period=3
    --log-period=300<br>
    ExecReload=/usr/bin/ldd /usr/local/bin/sync-periodically<br>
    RestartSec= 500ms<br>
    Restart=on-failure<br>
    RestartPreventExitStatus=254<br>
    Type=notify<br>
    KillMode=process<br>
    RuntimeDirectory=/var/run<br>
    RuntimeDirectoryMode=0755<br>
    <br>
    [Install]<br>
    WantedBy=multi-user.target<br>
    Alias=sync-periodically.service</font><br>
    </blockquote>
    <br>
    </p>
    <p>et pour une raison incompréhensible de moi (je connais mal <font
    face="monospace">systemd</font>)  il y a quatre processus <font
    face="monospace">sync-periodically</font></p>
    <p><font face="monospace">root@pcbasile:/# ps auxw|egrep
    'USER|sync-'<br>
    USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START  
    TIME COMMAND<br>
    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<br>
    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<br>
    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<br>
    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<br>
    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<br>
    root       55537  0.0  0.0   6464  2200 pts/3    S+   14:57  
    0:00 grep -E USER|sync-<br>
    <br>
    </font></p>
    <p><br>
    </p>
    <hr width="100%" size="2">
    <p><br>
    </p>
    <p>A la maison j'ai Ubuntu 22 (je vais peut-être installer Debian
    dans quelques jours)<br>
    </p>
    <p><font face="monospace"><font color="purple"><i>rimski %</i></font>
    /lib/systemd/systemd --version<br>
    systemd 251 (251.4-1ubuntu7)<br>
    +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<br>
    </font></p>
    <p><font face="monospace"><br>
    </font></p>
    <p>avec comme fichier <font face="monospace">/etc/systemd/system/sync-periodically.service</font>
    qui contient</p>
    <p><br>
    </p>
    <p><font face="monospace"># fichier
    /etc/systemd/system/sync-periodically.service<br>
    <br>
    [Unit]<br>
    Description=a service to sync(2) periodially our disks on Debian<br>
    Documentation=See <a class="moz-txt-link-freetext" href="https:///github.com/bstarynk/misc-basile.git">https:///github.com/bstarynk/misc-basile.git</a>
    files sync-periodically.{c,service}<br>
    After=network.target sshd.service<br>
    ConditionPathExists=!/etc/local/sync-periodically-dont-run<br>
    <br>
    [Service]<br>
    ExecStartPre=/bin/bash -c "[ -x /usr/local/bin/sync-periodically
    ]"<br>
    ExecStart=/usr/local/bin/sync-periodically --daemon
    --pid-file=/var/run/sync-periodically.pid --sync-period=3
    --log-period=300<br>
    ExecReload=/usr/bin/ldd /usr/local/bin/sync-periodically<br>
    RestartSec= 500ms<br>
    Restart=on-failure<br>
    RestartPreventExitStatus=254<br>
    Type=notify<br>
    KillMode=process<br>
    RuntimeDirectory=/var/run<br>
    RuntimeDirectoryMode=0755<br>
    <br>
    [Install]<br>
    WantedBy=multi-user.target<br>
    Alias=sync-periodically.service</font></p>
    <p>mais un seul processus avec <font face="monospace">ps auxw|egrep
    'USER|sync-'</font>:</p>
    <p>                 <font face="monospace"><br>
    USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START  
    TIME COMMAND<br>
    systemd+    1549  0.0  0.0  89644  6640 ?        Ssl  08:25  
    0:00 /lib/systemd/systemd-timesyncd<br>
    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<br>
    basilest 1820495  0.0  0.0   9060  2292 pts/5    S+   15:00  
    0:00 grep -E USER|sync<br>
    </font><br>
    </p>
    <p>Où est mon erreur, ou pourquoi une telle différence?</p>
    <p><br>
    </p>
    <p>Je serais même disposé à faire un paquet Debian, si ça pourrait
    être utile à d'autres.</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p>Merci<br>
    </p>
    <pre class="moz-signature" cols="72">--
    Basile Starynkevitch <a class="moz-txt-link-rfc2396E" href="mailto:basile@starynkevitch.net">&lt;basile@starynkevitch.net&gt;</a>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/

    </pre>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pierre Frenkiel@21:1/5 to All on Thu Nov 17 18:30:01 2022
    bonjour,

    est-il vraiment indispensable d'utiliser une telle usine a gaz, alors

    qu'avec un script comme
       while :
       do
          sleep 1
          sync
       done
    on ne perd qu'une seconde de travail
       ou sleep 10 si l'on accepte de perdre 10 secondes de travail
    Pierre Frenkiel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)