Usage: runlevel [OPTION]... [UTMP]
Output previous and current runlevel.
Options:
-q, --quiet reduce output to errors only
-v, --verbose increase output to include informational messages
--help display this help and exit
--version output version information and exit
The system /var/run/utmp file is used unless the alternate file UTMP is given.
Report bugs at
Usage: runlevel [OPTION]... [UTMP]
Output previous and current runlevel.
Options:
-q, --quiet reduce output to errors only
-v, --verbose increase output to include informational messages
--help display this help and exit
--version output version information and exit
The system /var/run/utmp file is used unless the alternate file UTMP is given.
Report bugs at
runlevel(8) runlevel(8)
名前
runlevel - 前のランレベルおよび現在のランレベルを出力する
書式
runlevel [OPTION]... [UTMP]
説明
runlevel は、代替ファイルが与えられなかった場合、直近のランレベルの記録
を探しだすために、システム UTMP ファイル (デフォルトでは /var/run/utmp
) を読み込む。
そ の記録から前のランレベルおよび現在のランレベルがひとつの空白で区切ら
れて出力される。もし記録に前のランレベルがない場合は、文字 N で置き換え
られる。
ランレベルの記録が見つからなかった場合は、 runlevel は文字列 unknown を
出力し、エラーとともに終了する。
システムが起動している間は、環境変数 RUNLEVEL と PREVLEVEL が init(8)
デーモンによって設定される。これらは telinit(8) あるいは shutdown(8) に
よって生成される runlevel(7) イベントによってもたらされる。
これらの環境変数が設定された場合、 runlevel は代わりにこれらの値を出 力
す る 。従って runlevel は System-V の who(1) -r コマンドの代用品として
rc スクリプトで利用することができる。
オプション
--quiet
現在のランレベルおよび前のランレベルの出力をせず、エラー発生時の
unknown も出力しない。(ただし、エラーコードとともに終了する)
これはランレベルエントリーの存在確認あるいはファイルの読み取りの
エラー確認のために使用される。
終了ステータス
UTMP レコードが存在した場合 runlevel はステータス 0 で終了する。さも な
ければステータス 1 で終了する。
環境変数
RUNLEVEL
もしこの環境変数が設定されている場合、 runlevel は /var/run/utmp
からの読み込みよりも優先して現在のランレベルをこの環境変数から読
み込む。
PREVLEVEL
RUNLEVEL が設定されている場合 runlevel は /var/run/utmp からの読
み込みよりも優先して前のランレベルをこの環境変数から読み込む。
ファイル
/var/run/utmp
現在のランレベルと前のランレベルはこのファイルから読み込まれる。
注意
Upstart の init(8) デーモンはランレベル自体を常に知っているわけではなく
、代わりにユーザースペースのツールで完全に実装される。
ランレベルの変更は telinit(8) あるいは shutdown(8) ツールによって生成さ
れ る runlevel(7) イベントによって通知される。このイベントは PREVLEVEL
環境変数内にある前のランレベル ( /var/run/utmp あるいは独自の環境変数か
ら取得されたもの ) と同様に RUNLEVEL 環境変数内の新しいランレベルを含む
。
イベント生成と同時に、両方のツールは新しいランレベルを /var/run/utmp へ
書き戻し、 /var/log/wtmp へ新しいエントリを追加する。
著者
Scott James Remnant
runlevel(8) runlevel(8)
NAME
runlevel - output previous and current runlevel
SYNOPSIS
runlevel [OPTION]... [UTMP]
DESCRIPTION
runlevel reads the system UTMP file, which defaults to /var/run/utmp
when no alternate filename is given, to locate the most recent runlevel
record.
The previous and current runlevel from that record are output separated
by a single space. If there is no previous runlevel in the record, the
letter N will be substituted.
If no runlevel record can be found, runlevel outputs the word unknown
and exits with an error.
During system boot, the environment variables RUNLEVEL and PREVLEVEL
will be set by the init(8) daemon, these come from the runlevel(7)
event generated by telinit(8) or shutdown(8).
When these environment variables are set, runlevel will output the val-
ues from these instead. Thus runlevel can be used in rc scripts as a
replacement for the System-V who(1) -r command.
OPTIONS
--quiet
Does not output the current and previous runlevel, nor does it
output unknown in the case of error (but it will exit with an
error code).
This may be used to test for the presence of a runlevel entry,
or to check for errors reading from the file.
EXIT STATUS
runlevel will exit with status 0 if a UTMP record was found, otherwise
it will exit with status 1.
ENVIRONMENT
RUNLEVEL
runlevel will read the current runlevel from this environment
variable if set in preference to reading from /var/run/utmp
PREVLEVEL
runlevel will read the previous runlevel from this environment
variable if RUNLEVEL
was given, in preference to reading from /var/run/utmp
FILES
/var/run/utmp
Where the current and previous runlevels will be read from.
NOTES
The Upstart init(8) daemon does not keep track of runlevels itself,
instead they are implemented entirely by its userspace tools.
A change of runlevel is signalled by the runlevel(7) event, generated
by either the telinit(8) or shutdown(8) tools. This event includes the
new runlevel in the RUNLEVEL environment variable, as well as the pre-
vious runlevel (obtained from their own environment or from
/var/run/utmp) in the PREVLEVEL variable.
As well as generating the event, both tools write the new runlevel back
to /var/run/utmp and append a new entry to /var/log/wtmp.
AUTHOR
Written by Scott James Remnant
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa