systemd:systemd
systemd
- Recharge / redémarre systemd :
$ systemctl daemon-reload $ systemctl daemon-reexec
- Affiche la liste des dépendances d'une unité :
$ systemctl list-dependencies nfs-client.target nfs-client.target ● ├─auth-rpcgss-module.service ● ├─rpc-statd-notify.service ● └─remote-fs-pre.target
- Afficher une propriété d'un service :
$ systemctl show -p "Wants" nfs.service Wants=rpcbind.socket network-online.target auth-rpcgss-module.service rpc-statd-notify.service nfs-config.service rpc-statd.service nfs-idmapd.service
- Liste l'arbre des cgroups :
$ systemd-cgls
- Affiche les uités :
$ systemctl list-unit-files --type=mount UNIT FILE STATE -.mount generated boot-efi.mount generated dev-hugepages.mount static dev-mqueue.mount static home.mount generated proc-fs-nfsd.mount static proc-sys-fs-binfmt_misc.mount static sys-fs-fuse-connections.mount static sys-kernel-config.mount static sys-kernel-debug.mount static tmp.mount static var-lib-machines.mount static var-lib-nfs-rpc_pipefs.mount static 13 unit files listed.
$ systemctl list-unit-files --state=generated UNIT FILE STATE -.mount generated boot-efi.mount generated home.mount generated livesys-late.service generated livesys.service generated netconsole.service generated network.service generated 7 unit files listed.
- Modifie un service existant ou en crée un nouveau :
$ sudo systemctl edit crond.service $ $ #Liste edite le service et recopiant le père $ sudo systemctl edit crond.service -l $ sudo systemctl edit crond.service -full
- Date pour timer :
Minimal form Normalized form Sat,Thu,Mon-Wed,Sat-Sun ==> Mon-Thu,Sat,Sun *-*-* 00:00:00 Mon,Sun 12-*-* 2,1:23 ==> Mon,Sun 2012-*-* 01,02:23:00 Wed *-1 ==> Wed *-*-01 00:00:00 Wed-Wed,Wed *-1 ==> Wed *-*-01 00:00:00 Wed, 17:48 ==> Wed *-*-* 17:48:00 Wed-Sat,Tue 12-10-15 1:2:3 ==> Tue-Sat 2012-10-15 01:02:03 *-*-7 0:0:0 ==> *-*-07 00:00:00 10-15 ==> *-10-15 00:00:00 monday *-12-* 17:00 ==> Mon *-12-* 17:00:00 Mon,Fri *-*-3,1,2 *:30:45 ==> Mon,Fri *-*-01,02,03 *:30:45 12,14,13,12:20,10,30 ==> *-*-* 12,13,14:10,20,30:00 mon,fri *-1/2-1,3 *:30:45 ==> Mon,Fri *-01/2-01,03 *:30:45 03-05 08:05:40 ==> *-03-05 08:05:40 08:05:40 ==> *-*-* 08:05:40 05:40 ==> *-*-* 05:40:00 Sat,Sun 12-05 08:05:40 ==> Sat,Sun *-12-05 08:05:40 Sat,Sun 08:05:40 ==> Sat,Sun *-*-* 08:05:40 2003-03-05 05:40 ==> 2003-03-05 05:40:00 2003-03-05 ==> 2003-03-05 00:00:00 03-05 ==> *-03-05 00:00:00 hourly ==> *-*-* *:00:00 daily ==> *-*-* 00:00:00 monthly ==> *-*-01 00:00:00 weekly ==> Mon *-*-* 00:00:00 *:20/15 ==> *-*-* *:20/15:00
Some other options like OnCalendar are available :
- OnActiveSec defines a timer relative to the moment the timer itself is activated.
- OnBootSec defines a timer relative to when the machine was booted up.
- OnStartupSec defines a timer relative to when systemd was started.
- OnUnitActiveSec defines a timer relative to when the unit the timer is activating was last activated.
- OnUnitInactiveSec defines a timer relative to when the unit the timer is activating was last deactivated.
Exemple :
[Unit] Description=Execute backup every day at midnight [Timer] OnCalendar=*-*-* 00:00:00 Unit=backup.service [Install] WantedBy=multi-user.target
- 2 moyens d'activer les processus persistants (qui continue après la fermeture de session) :
- loginctl enable-linger [user] : Active les processus persistant pour le user donné (si pas de user alors user courant). L'utilisateur peut alors utiliser la commande systemd-run pour lancer un process persistant, par exemple :systemd-run –scope –user /usr/bin/screen
- Dans le fichier
/etc/systemd/logind.conf
, définissez KillUserProcesses=no pour activer les processus persistant sur tout le système
systemd/systemd.txt · Dernière modification : 2017/11/08 20:55 de root