LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2014, 12:14 AM   #1
shri8
LQ Newbie
 
Registered: Jun 2014
Posts: 22

Rep: Reputation: Disabled
interface for calculating running time of process


I want to create a simple procfs interface to calculate the total running time of process.ie on cd /proc/pid/my_running i should get the running time of the given proces.How to do this?
 
Old 06-18-2014, 05:19 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
Already there.

Use the "ps" command to get the statistics you want.
 
Old 06-18-2014, 05:39 AM   #3
shri8
LQ Newbie
 
Registered: Jun 2014
Posts: 22

Original Poster
Rep: Reputation: Disabled
ps displays all the statistics of the process but i want to get only the total running time of particular process.
 
Old 06-18-2014, 05:48 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,729

Rep: Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123
Perhaps you should read the manpage for ps to learn how to control the output - much easier than writing a kernel module.
 
Old 06-18-2014, 07:15 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,437
Blog Entries: 12

Rep: Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895Reputation: 1895
Have a look at this thread, part of what the OP was doing was to calculate the CPU time for a process http://www.linuxquestions.org/questi...ss-4175505732/.
 
Old 06-19-2014, 03:53 AM   #6
shri8
LQ Newbie
 
Registered: Jun 2014
Posts: 22

Original Poster
Rep: Reputation: Disabled
as i am a beginner i want the steps or code to be followed for creating a simple procfs interface for calculating running time of a process.
 
Old 06-19-2014, 04:16 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
I think that is the wrong place to begin.

One reason is that procfs is deep in the kernel, with lots of interfaces scattered over the kernel. An error there could just crash a system, without giving sufficient information for debugging.

If you are a C programmer already, it would be better to start with the kernel newbies list and performing the slightly simpler "cleanup" functions first (http://kernelnewbies.org/). It will get you familiar with the kernel developers, style, and processes for better experience.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] total process time and time in present state(sleep/running/ uninterruptible). satyadev75 Linux - Server 1 05-16-2013 06:03 AM
Ethernet Interface leaves RUNNING state after some time earthlink Linux - Networking 1 07-31-2011 11:44 AM
Real running time of process soosho Programming 17 07-05-2008 01:16 PM
Trying to get ps to display time a process has been running in seconds kinetik Programming 1 02-26-2007 07:21 PM
Running time active process js_valencia Linux - General 6 02-15-2006 10:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration