{{tag>Brouillon SystemD}}
= Notes SystemD
Voir :
* [[Systemd journalctl journal logs|journalctl]]
* [[redhat_acces_var_log_mariadb_mariadb.log_sans_etre_root|systemd service dépendant d'un autre service]]
* https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
* https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files
* https://linuxembedded.fr/2021/11/limiter-les-ressources-dune-ligne-de-commande-avec-systemd
* [[https://linuxfr.org/users/samuel/journaux/durcir-nginx-et-php-avec-systemd|Durcir nginx et PHP avec systemd]]
[[https://github.com/konstruktoid/hardening/blob/master/systemd.adoc|Hardening Security focused systemd configuration]]
Lister les services
systemctl list-unit-files
systemctl list-units
Lister les services inactifs
systemctl list-units -all --state=inactive
Lister les services KO
systemctl -a |grep dead
Lister les services actifs
# SystemD
systemctl list-units --type service --state active
# Avant SystemD
chkconfig --list |grep -E '[1-5]:on'
Savoir si le service est activé ou désactivé
systemctl is-active httpd
systemctl is-enabled httpd
Relire la conf
systemctl daemon-reload
Les différents types de services
* http://doc.fedora-fr.org/wiki/Systemd#Type_de_service
Runlevel et Target
| **Runlevel** | **Target** |
| 0 | poweroff.target |
| 1 | rescue.target |
| 2, 3, 4 | multi-user.target |
| 5 | graphical.target |
| 6 | reboot.target |
== Contrôler des services (Units) SystemD distants avec Hirte
Voir :
* [[https://www.redhat.com/en/blog/introducing-hirte-deterministic-multi-node-service-controller]]
Exemple
hirtectl start rpi4 httpd.service
== Debug
systemctl show --property=Environment docker
== Autres
If you don't like systemctl's auto-paging feature
export SYSTEMD_PAGER=
=== Logs entre deux date
journalctl --since "2019-10-16 06:00" --until "2019-10-16 10:00"
=== Disable systemd redirection
export _SYSTEMCTL_SKIP_REDIRECT=1
=== tmpfile
[Service]
PrivateTmp=true
---
man -k tmpfiles
/etc/tmpfiles.d
x /tmp/pymp-*
=== reboot
systemctl reboot
=== Lang Locale
Voir [[notes_langue_lang_locale_temps_timezone_tz|Notes langue lang locale - SystemD]]
#timedatectl list-timezones
timedatectl set-timezone Europe/Paris
== Pb
=== RemoveIPC - Quand Poettering fait des siennes
Problème si compte UID > 1000 à cause de **RemoveIPC**
https://linuxfr.org/users/neologix/journaux/systemd-attention-a-removeipc
RemoveIPC Directive \\
A new option called RemoveIPC was introduced in RHEL 7.2 through Systemd v219. When set to yes, this option forces a cleanup of all allocated inter-process communication (IPC) resources linked to a user leaving his last session. If a daemon is running as a user with a uid number >=1000, it may crash.
This option should always be set to no by default but, due to the logic of package upgrade, it is highly advisable to set RemoveIPC=no in the /etc/systemd/logind.conf file followed by # systemctl restart systemd-logind (source).
Source : https://www.certdepot.net/rhel7-changes-between-versions/