User Tools

Site Tools


doc:appunti:linux:sa:systemd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:linux:sa:systemd [2018/05/23 12:03] – [Timeout in attesa di un device] niccolodoc:appunti:linux:sa:systemd [2024/11/15 15:01] (current) – [Verifica dipendenze servizi] niccolo
Line 152: Line 152:
 </file> </file>
  
 +===== Verifica Servizi =====
 +
 +Alcuni comandi utili per **verificare il funzionamento** dei servizi gestiti da **systemd**.
 +
 +Mostra lo stato di tutti i **servizi** e di tutte le **unit**:
 +
 +<code>
 +systemctl --all --full status
 +</code>
 +
 +Mostra le **unit** //required// e //wanted// dalla unit specificata:
 +
 +<code>
 +systemctl --all list-dependencies ntp.service
 +</code>
 +
 +===== Verifica dipendenze servizi =====
 +
 +Generates textual **dependency graph** description in //dot// format:
 +
 +<code>
 +systemd-analyze dot
 +systemd-analyze dot 'dhcpcd.*'
 +systemd-analyze dot dhcpcd.service
 +</code>
 +
 +Prints an **SVG graphic** detailing **which system services have been started at what time**:
 +
 +<code>
 +systemd-analyze plot > services-start-graph.svg
 +</code>
 +
 +Shows units **required** and **wanted** by the specified units:
 +
 +<code>
 +systemctl list-dependencies
 +systemctl list-dependencies dhcpcd.service
 +systemctl list-dependencies wpa_supplicant@..service
 +</code>
 +
 +  * **[[https://serverfault.com/questions/617398/is-there-a-way-to-see-the-execution-tree-of-systemd|Is there a way to see the execution tree of systemd?]]**
 +  * **[[https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html|systemd.unit — Unit configuration]]**
 +  * **[[https://www.freedesktop.org/software/systemd/man/latest/systemd.slice.html|systemd.slice — Slice unit configuration]]**
 +
 +===== Alternativa allo script rc.local =====
 +
 +Come eseguire uno script all'avvio di un sisetma Systemd.
 +
 +Creare una unit Systemd **/etc/systemd/system/my-startup.service**:
 +
 +<file>
 +# /etc/systemd/system/my-startup.service
 +#
 +# Service executed once the system has reached the multi-user status.
 +#
 +#  Type=oneshot         The unit is up after the main process exits.
 +#  RemainAfterExit=yes  The service shall be considered active even
 +#                       when all its processes exited.
 +#
 +# Eanble the service with:
 +#   systemctl enable my-startup.service
 +
 +[Service]
 +Type=oneshot
 +RemainAfterExit=yes
 +ExecStart=/usr/local/sbin/my-startup-script
 +
 +[Install]
 +WantedBy=multi-user.target
 +</file>
 +
 +Abilitare la unit e predisporre lo script **/usr/local/sbin/my-startup-script**.
  
 ===== Riferimenti web ===== ===== Riferimenti web =====
doc/appunti/linux/sa/systemd.1527069832.txt.gz · Last modified: 2018/05/23 12:03 by niccolo