
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to get the start time of a long running Linux Process?
Whenever we want to get an update about a specific process or different process we make use of the ps command which is short for “Process status” that tells us about the state of the current process and its characteristics and a whole lot more.
When clubbed with several flags and commands we can enhance the ps command to output the start time of different processes that are running on a particular Linux machine.
The command to print the time of long running processes in increasing order is shown below −
For Ubuntu and other Linux based Systems −
ps -eo pid , lstart , cmd
For Mac OS −
ps -eo pid , lstart , command
In the above command we are trying to make use of the process state utility provided by linux and then printing the process id, along with the lstart which will provide us the date+time started and then finally the command(name) of the process.
Output
immukul@192 linux-questions-code % ps -eo pid,lstart,command PID STARTED COMMAND 1 Fri Jun 25 23:14:44 2021 /sbin/launchd 56 Fri Jun 25 23:15:00 2021 /usr/sbin/syslogd 57 Fri Jun 25 23:15:00 2021 /usr/libexec/UserEventAgent (System)
It should be noted that the above command will print the output in the increasing order of the time and the most recent processes will be at the end of the output. In order to print the time in decreasing order we will need to make use of the sort command utility along with the above command. Consider the command shown below −
For Ubuntu and other Linux based Systems
Command
ps -eo pid , cmd , etime | sort -n -k2
For Mac OS
ps -eo pid , command , etime | sort -n -k2
Output
immukul@192 linux-questions-code % ps -eo pid,command,etime|sort -n -k2 1 /sbin/launchd 08-13:56:50 56 /usr/sbin/syslog 08-13:56:34 57 /usr/libexec/Use 08-13:56:34 60 /System/Library/ 08-13:56:34 61 /System/Library/ 08-13:56:34 62 /System/Library/ 08-13:56:34 65 /usr/sbin/system 08-13:56:34
- Related Articles
- Find the Current Working Directory of a Running Process in Linux
- How to show historical and statistical running time of linux systems
- Redirecting the Output of an Already Running Process on Linux
- How to run long time process on Udev event
- How can we get an ID of the running process in Java 9?
- How to get time in milliseconds using C++ on Linux?
- How to create a process in Linux?
- How to Clean a Linux Zombie Process
- How to check the syntax of a Bash script without running it in Linux?
- How to list running screen sessions on Linux?
- How to Get the Path of a Linux Command?
- How to Count the Number of Threads in a Process on Linux
- How to check Syntax of a Bash Script without running it in Linux?
- How to increase the scrollback buffer in a running screen session on Linux?
- How to find and kill running processes in linux
