#adsense(728x90)
拡張子 | 用途 |
.service | デーモンに関する設定 (/etc/init.d の代替) |
.mount | ファイル システム (/etc/fstab の代替) |
.socket | ソケットアクセスをトリガとした起動 (/etc/xinetd.d の代替) |
.device | |
.path | 特定のパスの状態をトリガとした起動 |
.target | 複数のユニットをまとめたもの |
[Unit] Description= [Service] ExecStart= Restart=always Type=simple [Install] WantedBy=multi-user.target
$ systemctl start unit
$ systemctl stop unit
$ systemctl restart unit
$ systemctl reload unit
$ systemctl status unit
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2019-04-11 07:47:08 EDT; 50s ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 1032 (sshd) CGroup: /system.slice/sshd.service └1032 /usr/sbin/sshd -D Apr 11 07:47:08 rhel7-test systemd[1]: Starting OpenSSH server daemon... Apr 11 07:47:08 rhel7-test sshd[1032]: Server listening on 0.0.0.0 port 22. Apr 11 07:47:08 rhel7-test sshd[1032]: Server listening on :: port 22. Apr 11 07:47:08 rhel7-test systemd[1]: Started OpenSSH server daemon. Apr 11 07:47:51 rhel7-test sshd[1292]: Accepted password for user from 192.168.56.1 port 53425 ssh2
ランレベル | ターゲット | 備考 |
0 | poweroff.target | |
1 | rescue.target | |
3 | multi-user.target | |
5 | graphical.target | multi-user.target に依存 |
6 | reboot.target |
# systemctl get-default target
# ls -l default.target lrwxrwxrwx. 1 root root 16 Mar 17 21:17 default.target -> graphical.target
# systemctl set-default target
# systemctl isolate target
# systemctl enable unit
# systemd-sysv-install enable
# systemctl disable unit
# systemctl list-unit-files --type service
STATE | |
enabled | 自動起動するユニット |
disabled | 自動起動しないユニット |
enabled-runtime | |
generated | systemd-sysv-install が生成したユニット (Ubuntu) |
indirect | |
masked | 自動起動せず、手動起動も出来ないユニット (無効化) |
static | [Install] セクションがないユニット 他ユニットから依存関係で起動する前提で、個別に enabled/disabled できない |
# systemctl is-enabled unit
$ systemctl is-enabled nginx.service enabled
# journalctl [option]
オプション | 意味 | 説明 |
-k | kernel | Kernel のログのみを出力 |
-u unit | unit | 特定ユニットのログのみを出力 |
_PID=pid | 特定プロセス ID のログのみを出力 | |
-x | 詳細なログを出力 | |
-f | follow | 新しいログを出力し続ける |
-r | reverse | 新しいもの順に出力 |
-n [number] | 末尾 number 行を出力 (デフォルトは 10) | |
-e | pager end | 末尾 1000 行を出力し、最後ページを表示する |
-b [num] | boot | 起動からすべてのログを出力 負数で num 回前の起動時のログ、正数で num 回目の起動時のログ (デフォルトでは再起動で消える) |
-S "YYYY-MM-DD hh:mm:ss" | since | 指定時間以降のログを出力 |
-U "YYYY-MM-DD hh:mm:ss" | until | 指定時間以前のログを出力 |
$ systemd-analyze Startup finished in 4.181s (kernel) + 8.623s (initrd) + 13.355s (userspace) = 26.160s
$ timedatectl status Local time: Tue 2018-05-01 16:39:59 JST Universal time: Tue 2018-05-01 07:39:59 UTC RTC time: Tue 2018-05-01 07:40:00 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
# timedatectl set-time YYYY-MM-DD HH:MM:SS # timedatectl set-time YYYY-MM-DD # timedatectl set-time HH:MM:SS
$ systemd-detect-virt microsoft
#adsense(728x90)