1runlevel(8)                 System Manager's Manual                runlevel(8)
2
3
4

NAME

6       runlevel - output previous and current runlevel
7

SYNOPSIS

9       runlevel [OPTION]...  [UTMP]
10

DESCRIPTION

12       runlevel  reads  the  system UTMP file, which defaults to /var/run/utmp
13       when no alternate filename is given, to locate the most recent runlevel
14       record.
15
16       The previous and current runlevel from that record are output separated
17       by a single space.  If there is no previous runlevel in the record, the
18       letter N will be substituted.
19
20       If  no  runlevel record can be found, runlevel outputs the word unknown
21       and exits with an error.
22
23       During system boot, the environment variables  RUNLEVEL  and  PREVLEVEL
24       will  be  set  by  the  init(8) daemon, these come from the runlevel(7)
25       event generated by telinit(8) or shutdown(8).
26
27       When these environment variables are set, runlevel will output the val‐
28       ues  from  these instead.  Thus runlevel can be used in rc scripts as a
29       replacement for the System-V who(1) -r command.
30

OPTIONS

32       --quiet
33              Does not output the current and previous runlevel, nor  does  it
34              output  unknown  in  the case of error (but it will exit with an
35              error code).
36
37              This may be used to test for the presence of a  runlevel  entry,
38              or to check for errors reading from the file.
39

EXIT STATUS

41       runlevel  will exit with status 0 if a UTMP record was found, otherwise
42       it will exit with status 1.
43

ENVIRONMENT

45       RUNLEVEL
46              runlevel will read the current runlevel  from  this  environment
47              variable if set in preference to reading from /var/run/utmp
48
49       PREVLEVEL
50              runlevel  will  read the previous runlevel from this environment
51              variable if RUNLEVEL
52               was given, in preference to reading from /var/run/utmp
53

FILES

55       /var/run/utmp
56              Where the current and previous runlevels will be read from.
57

NOTES

59       The Upstart init(8) daemon does not keep  track  of  runlevels  itself,
60       instead they are implemented entirely by its userspace tools.
61
62       A  change  of runlevel is signalled by the runlevel(7) event, generated
63       by either the telinit(8) or shutdown(8) tools.  This event includes the
64       new  runlevel in the RUNLEVEL environment variable, as well as the pre‐
65       vious  runlevel  (obtained  from  their   own   environment   or   from
66       /var/run/utmp) in the PREVLEVEL variable.
67
68       As well as generating the event, both tools write the new runlevel back
69       to /var/run/utmp and append a new entry to /var/log/wtmp.
70

AUTHOR

72       Written by Scott James Remnant <scott@netsplit.com>
73

REPORTING BUGS

75       Report bugs at <https://launchpad.net/upstart/+bugs>
76
78       Copyright © 2009 Canonical Ltd.
79       This is free software; see the source for copying conditions.  There is
80       NO  warranty;  not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
81       PURPOSE.
82

SEE ALSO

84       runlevel(7) init(8) telinit(8) shutdown(8) who(1)
85
86
87
88Upstart                           2009-07-09                       runlevel(8)
Impressum