admin_grundlagen:systemd_service_unit_files
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Beispiel für ein Service Unit
Unit File anlegen:
systemctl edit --full --force nc.service
- /etc/systemd/system/nc.service
[Service] ExecStart=/usr/bin/nc -l -p 5000
Syntax des Unit Files prüfen:
systemd-analyze verify nc.service
Systemd Konfiguration neu laden 2)
systemctl daemon-reload
Service starten
systemctl start nc
Start überprüfen
systemctl status nc
Beschreibung hinzufügen:
systemctl edit --full nc.service
- /etc/systemd/system/nc.service
[Unit] Description=my netcat service …
Beschreibung überprüfen
systemctl status nc
Beim Booten starten
systemctl edit --full nc.service
- /etc/systemd/system/nc.service
… [Install] WantedBy=multi-user.target
systemctl enable nc
Beispiel für ein User Service Unit
Sinnloses Skript anlegen:
mkdir ~/bin vim ~/bin/fillfs.sh
- ~/bin/fillfs.sh
#!/bin/bash dd if=/dev/zero of=/tmp/zero oflag=append conv=notrunc bs=1M
Als Benutzer Unit File anlegen:
systemctl --user edit --force --full fillfs.service
- ~/.config/systemd/user/fillfs.service
[Service] ExecStart=/home/nutzer45/bin/fill-fs.sh
Syntax des Unit Files überprüfen:
systemd-analyze --user verify fillfs.service
„Dienst“ starten:
systemctl --user start fillfs
Sehen was passiert:
systemctl --user status fillfs journalctl --user -fu fillfs watch -d df -h
vmstat daemon service unit
- /etc/systemd/system/vmstatd.service
[Unit] Description=VMSTAT as a Service [Service] Restart=on-failure RestartSec=10 EnvironmentFile=/etc/default/vmstatd #ExecStart=/bin/bash -c 'exec /usr/bin/vmstat -n -w -t 3 >> /tmp/vmstat.log' ExecStart=/bin/bash -c 'exec /usr/bin/vmstat $VMPARAM $VMDELAY >> $VMLOGFILE' [Install] WantedBy=basic.target
- /etc/default/vmstatd
VMPARAM="-n -w -t" VMDELAY="5" VMLOGFILE="/tmp/vmstat.log"
admin_grundlagen/systemd_service_unit_files.1534404155.txt.gz · Zuletzt geändert: 2018/08/16 07:22 von ingo_wichmann
