Show pageOld revisionsBacklinksAdd to bookExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Systemd ====== <code> systemctl status </code> show running units <code> systemctl </code> show available unit files <code> systemctl list-unit-files </code> enable unit <code> systemctl enable name.service </code> start unit <code> systemctl start name </code> after change unit file <code> systemctl daemon-reload </code> ===== Systemd as user ===== enable systemd for specific user <code> loginctl enable-linger <username> </code> * add user to systemd-journal group to permit journactl operations <code> usermod -a -G systemd-journal <user> </code> * modify /etc/systemd/journald.conf <code> [Journal] Storage=persistent </code> deprecated <file bash /etc/profile.d/systemd-user.sh> export XDG_RUNTIME_DIR="/run/user/$UID" export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" </file> new method <code> mkdir -p ~/.bashrc.d echo "export XDG_RUNTIME_DIR=/run/user/$(id -u)" > ~/.bashrc.d/systemd source ~/.bashrc.d/systemd </code> journalctl -u does not work. Use instead <code> journalctl --user --user-unit </code> ===== Systemd Timer ===== Una valida e più potente alternativa a cron, integrata in systemd, è rappresentata dai timers, di primo impatto soprattutto nell'aspetto supervisivo tramite journalctl, ma non solo (vedi risposta a questo quesito http://unix.stackexchange.com/questions/278564/cron-vs-systemd-timers). Per attivare un timer servono essenzialmente due cose: * Il timer: /etc/systemd/system/nms-restart.timer <code> [Unit] Description=Perform a nms resrtart [Timer] OnCalendar=hourly [Install] WantedBy=timers.target </code> * il servizio: /etc/systemd/system/nms-restart.service <code> [Unit] Description=Perform a nms restart [Service] Type=simple Nice=19 IOSchedulingClass=2 IOSchedulingPriority=7 ExecStart=/usr/local/sbin/nms-restart </code> Poi si avvia e abilita il timer: <code> sudo systemctl start nms-restart.timer sudo systemctl enable nms-restart.timer </code> Per la lista dei timer <code> systemctl list-timers --all </code> Per monitorare si usa journalctl in tutte le sue forme, per esempio: <code> journalctl -f -u nms-restart </code> zibaldone/linux/systemd.txt Last modified: 2024/06/04 15:00by sscipioni