mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
1.4 KiB
1.4 KiB
Find how long a process has run in UNIX
UNIX and Linux have commands for almost everything; if there is no command, you can check some important files in the /etc directory or in the /proc virtual filesystem to find out some useful information.
Table of contents
The easy way
If the program started today, ps also shows when:
$ ps -ef
UID PID PPID C STIME TTY TIME CMD
user 11610 11578 0 Aug24 ? 00:08:06 java -Djava.library.path=/usr/lib/jni:/usr/lib/alpha-linux-gnu/jni...
user 17057 25803 0 13:01 ? 00:00:24 /usr/lib/chromium-browser/chromium-browser
The hackish way
Useful if the process started before today:
-
find the process ID
$ ps -ef | grep java user 22031 22029 0 Jan 29 ? 24:53 java -Xms512M -Xmx512 Server $ pgrep -l java 22031 java -
look into the
procvirtual filesystem for that process and check the creation date, which is when the process was startedls -ld /proc/22031 dr-x--x--x 5 user group 832 Jan 22 13:09 /proc/22031