DEV Community

Fomalhaut Weisszwerg
Fomalhaut Weisszwerg

Posted on

4 2

systemd-timesyncd を無効化する方法

Introduction.

Linux で時刻同期といえば ntpd が有名ですが、最近は systemd のサービスである systemd-timesyncd が使われることが増えています。時刻同期を無効にしたい、けど手元の環境には ntpd が入っていないみたいだという場合はもしかしたら systemd-timesyncd が使われているのかもしれません。

この記事では systemd-timesyncd が使われているのかどうかを調べる方法と、systemd-timesyncd を無効化する方法、再度有効化する方法を解説します。

systemd-timesyncd が使われているか調べる方法

ターミナルで下記コマンドを実行します。



systemctl status systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

systemd-timesyncd が使われている場合、下のスクリーンショットのようにコマンドの出力に "Active: active (running)" という文字列が確認できます。

Result when systemd-timesyncd is active and running

一方で systemd-timesyncd が使用されていない場合は "Active: inactive (dead)" という文字列が確認できます。

Result when systemd-timesyncd is inactive and not running

systemd-timesyncd による時刻同期を無効化する方法

無効化にはルート権限が必要です。

最初に動作中の systemd-timesyncd サービスを停止します。次のコマンドを実行します。



sudo systemctl stop systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

次に systemd-timesyncd サービスを無効化します。次のコマンドを実行します。



sudo systemctl disable systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

最後にサービスの状態を確認します。次のコマンドを実行します。



systemctl status systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

"Active: active (running)" と表示されていた行が "Active: inactive (dead)" に変わっていれば無効化は完了です。OS 再起動の必要はありません。

disable systemd-timesyncd

systemd-timesyncd を再度有効化する方法

再有効化にはルート権限が必要です。

最初に systemd-timesyncd サービスを有効化します。下記のコマンドを実行します。



sudo systemctl enable systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

次にサービスを起動します。有効化しただけではサービスが起動していないからです。



sudo systemctl start systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

最後にサービスの状態を確認します。下記コマンドを実行します。



systemctl status systemd-timesyncd


Enter fullscreen mode Exit fullscreen mode

"Active: inactive (dead)" と表示されていた行が "Active: active (running)" に変わっていれば再有効化は完了です。OS 再起動の必要はありません。

re-enable systemd-timesyncd

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay