

#Utime unix command line install
For example, if a server needs to be rebooted every month to install the latest security patches and firmware updates, a simple script can be created to continuously read the output of the /proc/uptime file.

Similarly, the top command uses both of the values found in the /proc/uptime file to calculate the CPU’s idle time percentage.Īnother use for the /proc/uptime file is that you can read it in your custom scripts and use its output for various use cases.

So, the /proc/uptime file is actually the most accurate source of information for every command that deals with uptime and idle time.Ĭommands like uptime and w use the output of this file to get uptime measured in seconds and then render them in different formats. This means that whenever you view the contents of the file, the kernel recalculates the value of uptime and idle time and then displays the result. Like any other file in the proc file system, the contents of the /proc/uptime file are generated on the fly. So, what’s the use of the /proc/uptime file if there are already various commands serving the same purpose? Unlike the /proc/uptime file, these commands show the uptime in an attractive format or human-readable form. There are many commands that display system uptime, such as uptime, w, and top. Consequently, the overall system idle time may be greater than the overall system uptime on multi-core systems.įor example, running the cat /proc/uptime command on a Linux system regenerates the /proc/uptime file with the following information: For example, if a quad-core CPU is idle for 1 second, then the overall system idle time will be 4 seconds. In a multi-core system, the second value in the /proc/uptime is the combined idle time of each CPU. The system idle time in seconds-i.e., the total number of seconds the machine has been idle.The system uptime in seconds-i.e., the total number of seconds the system has been running since its last restart.The /proc directory contains a file named/uptime that provides the following information: The /proc file system is generated when the system boots, and it’s removed when the system shuts down. Files in the /proc directory contain detailed information about kernel, processes, system memory, and hardware configuration. It contains information about the system and the processes it’s currently running. proc is a virtual or pseudo-filesystem, also known as a process information pseudo-filesystem. You can also read the /proc/uptime file to get the system uptime.
