1753939 Members
9330 Online
108811 Solutions
New Discussion юеВ

linux commands

 
karunesh reddy
Occasional Contributor

linux commands

Red hat 7.2 linux

1. how can i check for how long ( in
days ,hours and mintues) has it been
since the system was last boot?

2.what command will let me check for
how many contex switches has the
kernel performed.
-
2 REPLIES 2
Stuart Browne
Honored Contributor

Re: linux commands

The first, any Unix user should know:

uptime

Using 'last' should also show you similar details about startup/shutdown/crashes of the system (assuming you don't rotate your utmp/wtmp files).

The latter isn't quite so nice. See if 'sar -w' is enough for you (shows context switches per second). Beyond that, I'm afraid I don't know of any command to do it.
One long-haired git at your service...
Ralph Grothe
Honored Contributor

Re: linux commands

Hi part 1 of your question has already been answered.
Either use the "uptime" command, or
cat /proc/uptime
The first number is the uptime of your system since last reboot in seconds.
Of course you would still have to drill this down to hours, minutes, seconds.

The answer to your 2nd question can also be retrieved from the /proc virtual filesystem (see "man proc" for a complete reference):

# awk '$1~/ctxt/{print $2}' /proc/stat
14308473
Madness, thy name is system administration