Systemd Praxis Lösungen
Version vom 10. Januar 2023, 11:10 Uhr von Linkai.zhang (Diskussion | Beiträge)
Erstellen von Units
- cat /etc/systemd/system/date1.service
[Unit] Description=Simple Unit [Service] Type=simple ExecStart=/usr/local/sbin/test-system.sh 1 [Install] WantedBy=default.target
- cat /etc/systemd/system/date2.service
[Unit] Description=Simple Unit [Service] Type=simple ExecStart=/usr/local/sbin/test-system.sh 2 [Install] WantedBy=default.target
- cat /etc/systemd/system/date3.service
[Unit] Description=Simple Unit [Service] Type=simple ExecStart=/usr/local/sbin/test-system.sh 3 [Install] WantedBy=default.target
- systemctl start date1
- systemctl start date2
- systemctl start date3
- tail /tmp/test-system.log
Analyse der gestarteten Units
- RemainAfterExit=yes hinterlässt den Service im activen Zustand
- systemctl status date3
● date3.service - Simple Unit
Loaded: loaded (/etc/systemd/system/date3.service; disabled; vendor preset: enabled)
Active: active (exited) since Tue 2023-01-10 11:17:02 CET; 40min ago
Main PID: 11089 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 1129)
Memory: 0B
CPU: 0
CGroup: /system.slice/date3.service
Jan 10 11:17:02 debian-test systemd[1]: Starting Simple Unit...
Jan 10 11:17:02 debian-test systemd[1]: Finished Simple Unit.
- systemctl status date1
● date1.service - Simple Unit Loaded: loaded (/etc/systemd/system/date1.service; disabled; vendor preset: enabled) Active: inactive (dead) since Tue 2023-01-10 12:02:16 CET; 46s ago Process: 13868 ExecStart=/usr/local/sbin/test-system.sh 1 (code=exited, status=0/SUCCESS) Main PID: 13868 (code=exited, status=0/SUCCESS) CPU: 7ms Jan 10 12:02:16 debian-test systemd[1]: Starting Simple Unit... Jan 10 12:02:16 debian-test systemd[1]: date1.service: Succeeded. Jan 10 12:02:16 debian-test systemd[1]: Finished Simple Unit.