systemd - modern Linux init
Hər müasir Linux distrosu (Ubuntu 16+, Debian 8+, AlmaLinux 8+) systemd istifadə edir. Xidmətləri başlatma, dayandırma, boot-da avtomatik açma - hamısı systemd ilə.
Status yoxlamaq
sudo systemctl status nginx sudo systemctl status mysql
Yaşıl "active (running)" görünməlidir.
Başlatma/dayandırma
sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl reload nginx # konfiq yenilə (downtime yoxdur)
Boot-da avtomatik başlatma
sudo systemctl enable nginx sudo systemctl disable nginx
Status fast check
sudo systemctl is-active nginx # active sudo systemctl is-enabled nginx # enabled
Bütün xidmətlər
sudo systemctl list-units --type=service --state=running
Custom xidmət yaratmaq
Misal: Node.js tətbiqim sistem boot-da başlasın.
sudo nano /etc/systemd/system/myapp.service
[Unit] Description=My Node.js app After=network.target [Service] Type=simple User=www-data WorkingDirectory=/var/www/myapp ExecStart=/usr/bin/node app.js Restart=on-failure RestartSec=5 StandardOutput=append:/var/log/myapp.log StandardError=append:/var/log/myapp-error.log Environment=NODE_ENV=production Environment=PORT=3000 [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable myapp sudo systemctl start myapp
Logları görmək
sudo journalctl -u myapp -f # canlı sudo journalctl -u myapp --since today sudo journalctl -u myapp -n 100 # son 100 sətir
Crash sonra restart
Yuxarıda Restart=on-failure ilə tətbiq çökərsə 5 saniyə sonra yenidən başladılır.
Boot vaxtını analiz
systemd-analyze blame
Hansı xidmət ən çox vaxt aldı sıralı göstərir.