LoginSignup
411
430

More than 5 years have passed since last update.

CentOS7で使われているsystemctlについて少しまとめた

Last updated at Posted at 2014-07-08

Linux女子部 systemd徹底入門が詳しい。

systemdに移行していくディストリビューション

RHEL 7 に採用される systemctl コマンド - /dev/null blogより

postfixなどの個別サービス設定は以下のファイルに書いてある。

/etc/systemd/system/multi-user.target.wants/postfix.service

開いてみると、monitのような書き方。

一覧は以下にある。

サービス一覧
ls /usr/lib/systemd/system/
/etc/systemd/system/*.wants

ここにリンク貼られている。

よく使いそうなディレクトリは以下

/etc/systemd/system/multi-user.target.wants/*.wants

例えば、sshd, crond, postfixは以下で登録されている。

  • /etc/systemd/system/multi-user.target.wants/sshd.service
  • /etc/systemd/system/multi-user.target.wants/crond.service
  • /etc/systemd/system/multi-user.target.wants/postfix.service

Systemd入門(2) - Serviceの操作方法 - めもめもより

稼働中のサービス
systemctl list-units --type=service
定義されているサービス一覧
systemctl list-unit-files --type=service
サービス状態
systemctl status sshd
systemctl is-enabled sshd
  • is-active -- Check whether units are active
  • is-enabled -- Check whether unit files are enabled
  • is-failed -- Check whether units are failed
ログを省略せずに表示
systemctl status sshd -l
従来のchkconfigリスト
chkconfig --list

ログの見方

systemd-journalグループで実行
systemctl status postfix
journalctl -u postfix
journalctl -u postfix -f
journalctl --since=today -u postfix
journalctl --since=yesterday -u postfix
journalctl --no-page -l --since="2014-09-22 12:00:00" --until="2014-09-29" -u postfix
journalctl -p4 -l --since="2014-09-22 12:00:00" --until="2014-09-29" -u postfix
journalctl /usr/bin/procmail
journalctl /usr/bin/dovecot

ログサイズの制限

journalサイズ確認
$ sudo du -sh /var/log/journal
3.1G    /var/log/journal
/etc/systemd/journald.conf
- #SystemMaxUse=
+ SystemMaxUse=50M
journald再起動
systemctl restart systemd-journald
journalサイズ確認
$ journalctl --disk-usage
Journals take up 408.1M on disk.

リモートのsystemctlを実行

systemctl status postfix -H server1
  • ssh経由でsystemctlを実行。~/.ssh/config が使える。

その他参考リンク

411
430
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
411
430