Unix administration - Querying run level

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > May 2005 > Querying run level





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Querying run level
Mister Anon

2005-05-03, 6:00 pm

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


Thanks.
Dragan Cvetkovic

2005-05-03, 6:00 pm

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 !!!
Ulrich Herbst

2005-05-03, 6:00 pm

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
matt_left_coast

2005-05-03, 6:00 pm

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.
Dragan Cvetkovic

2005-05-03, 6:00 pm

matt_left_coast <Not@given.org> writes:

> Mister Anon wrote:
>
>
> 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 !!!
Ulrich Herbst

2005-05-05, 2:51 am

Keith Thompson <kst-u@mib.org> writes:

> Ulrich Herbst <ulrich.herbst@gmx.de> writes:
>
> 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
Dragan Cvetkovic

2005-05-05, 7:49 am

Ulrich Herbst <ulrich.herbst@gmx.de> writes:

> Keith Thompson <kst-u@mib.org> writes:
>
[vbcol=seagreen]
> 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 !!!
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com