![]() You can achieve the same with: ps axo pid,user,cmd,lstart Thank you sooo much for this informative post. Great post, It really helped me, thank you I want to display the process created date & time only in Unix ? It's possible to change the timestamp by just 'touching' the directory. Example: using Ubuntu 10.4 the timestamps are updated once a day by some cron job. The timestamp of the /proc/pid file is changed under certain conditions. The process start time drift you've seen in ps is probably related to this:ĭue to the way that the start time of a process is calculated by ps (/proc/stat btime + /proc/PID/stat jiffies since process start) when NTP adjusts the system clock forward over time the start time of long running processes drifts. This will give start time in jiffies since last system reboot. the difference is usually 1 second (probably a rounding error). i've seen situations where 'ps' can return different start time for a given process with subsequent invocations. Lol! indeed sujeet suggestion is complete and excelent! look at this output:ġ2547 Mon Jun 1 15:50:02 2009 dcopserver -nosidġ6642 Sun Jun 7 03:50:58 2009 ps -eo pid,lstart,cmdġ6643 Sun Jun 7 03:50:58 2009 grep -colour=auto psĪctually, using 'ps' on linux is not always reliable. If you want the timestamp : date -d "`ps -p _PID_ -o lstart=`" +'%s'Īnother simple way to know process start time: But using the elapsed time still works - or the lstart format option to ps as sujeet suggested. For example on my PC most entries changed their time today at 19:29 for some reason. Looking at the mtime of /proc/PID may not yield useful results. Greetings from Argentina, MarianoĪnother simple way to know process start time: ps -eo pid,lstart,cmd enjoy If you can think of another clever way to get the start time and date, please let us know. You can tell from the timestamp that the process 1218 began executing on Sept 20, 16:14. Then, use the ls command to display the creation timestamp of the directory.ĭr-xr-xr-x 5 peter peter 0 Sep 20 16:14 /proc/1218 ![]() Get the process pid and read off the timestamp in the corresponding subdirectory in /proc.įirst, get the process pid using the ps command ( ps -ef or ps aux) If you prefer the BSD notation, issue this command:ġ218 /usr/lib/iceweasel/firefox-bin - 2-16:04:57 To find the exact time, you need to do some simple math. ![]() The firefox command started execution 2 days, 16 hours, 4 minutes and 45 seconds ago. dd is the number of days hh, the number of hours mm, the number of minutes ss, the number of seconds. The above ps command specifies 3 fields to be included in the output: the process pid, the command, and the elapsed time, respectively.Įtime is the elapsed time since the process was started, in the form dd-hh:mm:ss. Specify elapsed time in the ps output format.ġ218 /usr/lib/iceweasel/firefox-bin - 2-16:04:45 There are (at least) 2 ways to determine the exact start time if the process was started before the current day. The Start column in the above output only reveals the start date if the process is older than the current day. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND If the BSD notation is more familiar to you, you will find that ps aux yields similar results. The default ps -ef only tells you the start date but NOT the time if a process was NOT started on the same day. The STIME for process 1218 reads Sep20 (which was yesterday). What is the start time for the other process, the firefox process with pid 1218? But on what day, today?įrom the ps man page: 'Only the year will be displayed if the process was not started the same year ps was invoked, or "mmmdd" if it was not started the same day, or "HH:MM" otherwise.' From the above, we can tell that process 4901 (emacs) began execution at 16:34 (4:34 pm). ![]() The STIME column displays the start time or date. If ps -ef is what you use, that is the UNIX notation. Most Linux command-line users are familiar with either the standard UNIX notation or the BSD notation when it comes to specifying ps options. The venerable ps command deserves first consideration. How can we determine when a running process was started?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |