Querying run level - Unix

This is a discussion on Querying run level - Unix ; Is it possible for a program or a shell script to query from the system what runlevel it's in? Thanks....

+ Reply to Thread
Results 1 to 8 of 8

Thread: Querying run level

  1. Querying run level

    Is it possible for a program or a shell script to query from the
    system what runlevel it's in?


    Thanks.

  2. Re: Querying run level

    themf@graffiti.net (Mister Anon) writes:

    > Is it possible for a program or a shell script to query from the
    > system what runlevel it's in?
    >


    Depends. Some systems provide this information in 'who -r', some don't
    (e.g. some distributions of Linux).

    Dragan

    --
    Dragan Cvetkovic,

    To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

    !!! Sender/From address is bogus. Use reply-to one !!!

  3. Re: Querying run level

    themf@graffiti.net (Mister Anon) writes:

    > Is it possible for a program or a shell script to query from the
    > system what runlevel it's in?
    >
    >
    > Thanks.


    Try "ps -ef | grep init".
    on some (most ?) systems, the runlevel is written like
    init [2]

    Uli

    --
    '''
    (0 0)
    +------oOO----(_)--------------+
    | |
    | Ulrich Herbst |
    | |
    | Ulrich.Herbst@gmx.de |
    +-------------------oOO--------+
    |__|__|
    || ||
    ooO Ooo

  4. Re: Querying run level

    Mister Anon wrote:

    > Is it possible for a program or a shell script to query from the
    > system what runlevel it's in?
    >
    >
    > Thanks.


    I don't know what OS you are using, but with Mandrake Linux there is
    "runlevel" or "who -r" in solaris.

  5. Re: Querying run level

    matt_left_coast writes:

    > Mister Anon wrote:
    >
    >> Is it possible for a program or a shell script to query from the
    >> system what runlevel it's in?
    >>
    >>
    >> Thanks.

    >
    > I don't know what OS you are using, but with Mandrake Linux there is
    > "runlevel" or "who -r" in solaris.


    "who -r" works also on AIX and most modern Linux distros (old RH based
    distros didn't accept who -r and therefore had need for, above mentioned,
    runlevel command).

    Of course, BSDes don't have 'who -r' as they don't have a concept of run
    levels.

    Dragan

    --
    Dragan Cvetkovic,

    To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

    !!! Sender/From address is bogus. Use reply-to one !!!

  6. Re: Querying run level

    Ulrich Herbst writes:
    > themf@graffiti.net (Mister Anon) writes:
    >
    >> Is it possible for a program or a shell script to query from the
    >> system what runlevel it's in?
    >>
    >>
    >> Thanks.

    >
    > Try "ps -ef | grep init".
    > on some (most ?) systems, the runlevel is written like
    > init [2]


    Not on most of the systems I've tried. I see it on my Fedora Core 2
    system, but not on Red Hat (several versions), Solaris, or AIX.

    --
    Keith Thompson (The_Other_Keith) kst-u@mib.org
    San Diego Supercomputer Center <*>
    We must do something. This is something. Therefore, we must do this.

  7. Re: Querying run level

    Keith Thompson writes:

    > Ulrich Herbst writes:
    > > themf@graffiti.net (Mister Anon) writes:
    > >
    > >> Is it possible for a program or a shell script to query from the
    > >> system what runlevel it's in?
    > >>
    > >>
    > >> Thanks.

    > >
    > > Try "ps -ef | grep init".
    > > on some (most ?) systems, the runlevel is written like
    > > init [2]

    >
    > Not on most of the systems I've tried. I see it on my Fedora Core 2
    > system, but not on Red Hat (several versions), Solaris, or AIX.
    >

    OK,
    "ps -ef | grep init" does work on:
    RH9: yes
    Debian: yes
    RH EL4: yes
    AIX: no
    HP/UX 11: no
    Solaris: no
    Irix: no

    => "ps -ef | grep init" seems to work on many linux systems, but not
    on many commercial unixes.

    Uli

    --
    '''
    (0 0)
    +------oOO----(_)--------------+
    | |
    | Ulrich Herbst |
    | |
    | Ulrich.Herbst@gmx.de |
    +-------------------oOO--------+
    |__|__|
    || ||
    ooO Ooo

  8. Re: Querying run level

    Ulrich Herbst writes:

    > Keith Thompson writes:
    >
    >> Ulrich Herbst writes:
    >> > themf@graffiti.net (Mister Anon) writes:
    >> >
    >> >> Is it possible for a program or a shell script to query from the
    >> >> system what runlevel it's in?
    >> >>


    >> > Try "ps -ef | grep init".
    >> > on some (most ?) systems, the runlevel is written like
    >> > init [2]

    >>
    >> Not on most of the systems I've tried. I see it on my Fedora Core 2
    >> system, but not on Red Hat (several versions), Solaris, or AIX.
    >>

    > OK,
    > "ps -ef | grep init" does work on:
    > RH9: yes


    Not on our RH9 system either:

    hector$ /bin/ps -fe | grep '[i]'nit
    root 1 0 0 Mar30 ? 00:00:04 init
    hector$ cat /etc/issue
    Red Hat Linux release 9 (Shrike)
    Kernel \r on an \m

    hector$ uname -r
    2.4.20-35_39.rh9.at

    > Debian: yes
    > RH EL4: yes
    > AIX: no
    > HP/UX 11: no
    > Solaris: no
    > Irix: no
    >
    > => "ps -ef | grep init" seems to work on many linux systems, but not
    > on many commercial unixes.


    In other words, it works nowhere except on (some) Linux systems :-)

    'who -r' is more common.

    Dragan

    --
    Dragan Cvetkovic,

    To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

    !!! Sender/From address is bogus. Use reply-to one !!!

+ Reply to Thread