記事:
[Service] Restart=on-failure
記事:
確認方法:
proc_user=chrony proc_name=chronyd pgrep -u $proc_user $proc_name 64195 sudo pkill -u $proc_user $proc_name # systemdで再起動され、pidが変わったか確認 pgrep -u $proc_user $proc_name # ログの確認 sudo service $proc_name status ... # Activeが起動した時間に変わっている Active: active (running) since ... # ログに起動時のログが出ている
[Service] Environment="MYENV=dummy"
sudo systemctl daemon-reload sudo service myservice restart # 値が設定されているか確認 systemctl show myservice.service | grep -i -E "Env"
grep -i umask /proc/$(pgrep -u chrony chrony)/status Umask: 0022
systemctl show chrony.service | grep -i -E "umask" UMask=0022
例: apacheでログファイルのパーミッションを664にしたい。
[Service] UMask=0002
sudo systemctl daemon-reload sudo service httpd restart
[Unit] ... After=network-online.target
/usr/lib/systemd/system/<unit>.service
/etc/systemd/system/<unit>.d/<any>.conf
sudo systemctl edit nginx.service -- [Service] ExecStart= ExecStart=<new config> -- # 以下が自動生成される /etc/systemd/system/nginx.service.d/override.conf
sudo systemctl edit logrotate.timer # 以下が自動生成される /etc/systemd/system/logrotate.timer.d/override.conf
systemctl show nginx # OR systemctl show nginx -p ExecStart
ExecStart=/path/to/program > /var/log/program.log
sudo journalctl -u logrotate
sudo journalctl -p err
# 昨日からのログを表示 sudo journalctl --since="yesterday"
grep TimeoutStart /etc/systemd/system.conf #DefaultTimeoutStartSec=90s
for pid in $(pgrep mongod); do sudo cat /proc/$pid/limits | grep -P "open"; done Max processes 64000 64000 processes Max open files 64000 64000 files
sudo mkdir /etc/systemd/system/mongod.service.d sudo vim /etc/systemd/system/mongod.service.d/limits.conf -- # https://docs.mongodb.com/manual/reference/ulimit/ # # The settings is what mongoDB officially recommends. # [Service] # Other directives omitted # (file size) LimitFSIZE=infinity # (cpu time) LimitCPU=infinity # (virtual memory size) LimitAS=infinity # (open files) LimitNOFILE=64000 # (processes/threads) LimitNPROC=64000 -- sudo systemctl daemon-reload sudo service mongod restart
systemctl show service -p TimeoutStartUSec TimeoutStartUSec=1min 30s
sudo vim /etc/systemd/system/mongod.service.d/timeout.conf -- [Service] TimeoutStartSec=3m -- sudo systemctl daemon-reload systemctl show mongod -p TimeoutStartUSec TimeoutStartUSec=3min