LoginSignup
1
1

More than 1 year has passed since last update.

cronとrtcwakeでLinuxの自動起動及び自動シャットダウン

Last updated at Posted at 2019-11-24

概要

Ubuntuで録画サーバを動かしていると電気代がバカにならないので、
使わない時間帯(自分の場合は3時~20時)に合わせて、自動起動と自動シャットダウンができるようにしてみた。

今回は以下の2つのコマンドを使います。
#crontab -e

分(0-59) 時(0-23) 日(1-31) 月(1-12) 曜日(0-7) コマンド

*でワイルドカード指定が可能
#rtcwake

sudo rtcwake -m [モード] -s [復帰までの秒数]

-m off シャットダウン
-m disk 休止
-m mem サスペンド
#設定
今回はcronでrtcwakeコマンドをスケジュール実行させました。

# 3時にシャットダウンし、20時に起動させる場合
0 3 * * * sudo rtcwake -m off -s 61200
1
1
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
1
1