0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS学習記録(Linuxについて)

0
Posted at

使用教材

今回はLinuxのsystemdについて

systemdとは

  • systemdとはLinuxにおける「サービス」のこと
  • 起動順序としては電源→BIOS→ブートローダー→カーネル→systemdの順
  • systemdの起動時に事前配置されたユニットファイル(アプリケーションの実行環境を定義したもの)が動作する

ユニットファイル

  • セクションとしてはUnit、Service、Installに分かれる
[Unit]
Description:詳細説明
After:ユニットファイル同士の依存関係。起動する順序。

[Service]
Type:実行方法の定義1:simple(デフォルト。ExecStartのコマンドがそのままのメインプロセス)、2,forking(ExecStartの子プロセスがメイン)、3,oneshot(1度だけ実行するスクリプト)、4,notify(simpleと同様だが利用可能時にsystemへ通知する)

EnviromentFile:実行時に取り込む環境変数定義ファイル

ExecStart:実行するコマンド

Restart、RestartSec:アプリ停止時の再起動設定

[Install]
WantedBy:システム起動時の自動実行設定。通常は「multi-user.target」

systemdへの登録について

ユニットファイルを配置するパス
/etc/systemd/system/<Unit_File>

ユニットファイルをsystemdに読み込ませるコマンド
systemctl demon-reload

サービス一覧確認
systemctl list-unit-files

サービス状態確認
systemctl status <Unit_name>

サービスの開始/終了

systemctl start <Unit_name>
systemctl stop <Unit_name>

サービス自動起動の有効/無効

systemctl enable <Unit_name>
systemctl disenable <Unit_name>
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?