You are not logged in.

#1 2006-06-11 01:32:03

russianpirate
Member
Registered: 2006-05-17
Posts: 161

A daemon/script that records how long a program is running..

I just want a daemon that records how long a program is running.. just wanna see how much time I spend gaming, browsing, listening to music, etc.


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#2 2006-06-11 01:58:23

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: A daemon/script that records how long a program is running..

you might be interested in the 'time' command.  Here's a totally useless but demonstrative example:

$ time for i in `seq 1 100000`; do echo $i > /dev/null; done

real    0m6.434s
user    0m4.231s
sys     0m1.369s

Offline

#3 2006-06-11 02:52:55

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

That's cpu usage, not the length of a program existing in memory

But thanks anyway


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#4 2006-06-11 03:27:06

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: A daemon/script that records how long a program is running..

russianpirate wrote:

That's cpu usage, not the length of a program existing in memory

But thanks anyway

no, it does exactly what you want to do. see 'real' ?

[root@sara iphitus]# time sleep 5
real    0m5.002s
user    0m0.001s
sys     0m0.000s

Offline

#5 2006-06-11 04:12:15

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

hmm is it possible to somehow integrate it and make it automatically run when a certain command is launched (i dont want to monitor everything.. lol) and then save the date before time is launched and after... for the record.. in fact a simple "BEF=`date`; app; AFT=`date`; TIM=$AFT-$BEF; echo $TIM > time.app" could work.. of course u need to modify it to diplay only time and with only numbers (ex. 1802-1200 =602.. so it ran for 6 hours and 2 min wink) this is also dirty and if anyone could come up with a sufficiently clean and resource-friendly daemon to do this, i would appreciate it wink


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#6 2006-06-11 07:59:32

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

working on a perl script right now.. (my first one lol)

i have an idea of how i can actually pull this off big_smile


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#7 2006-06-11 11:10:28

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

Ok well i wrote a script (actually 4 lol) totalling to 3kb of script code (a lot for me..)

The script itself only needs 1-3mb of RAM and 0% CPU when the program is running..
It records how long the program has been on for into a file (individual per program) when the program closes, when it is started again, a new entry is added to the same file and at the end of it..a "Total:" line is added showing the total amount of time it has ever been running

It is a pretty good script and I COULD just add aliases to .bashrc but this isnt perfect and you have to wait until the program is closed to view how long it ran for.. also if anything besides bash runs it.. it wont work (for example opening mp3s or docs from nautilis or launching firefox from other apps, etc.

Well it took me about 3-4 hours to write this, and it's my first actually useful script so im glad i did it..

I hope someone can write a real daemon in C++ or other language that is better and more functional big_smile Please..


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#8 2006-06-11 12:24:35

stavrosg
Member
From: Rhodes, Greece
Registered: 2005-05-01
Posts: 330
Website

Re: A daemon/script that records how long a program is running..

Care to share it in the User Contributions forum?
I am sure that at least one more person will find this useful, and you can end up with fixes and encasements from other people for free. wink

Offline

#9 2006-06-11 14:43:12

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#10 2006-06-11 16:51:06

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

I just looked in gnome-system-monitor and it shows when the program was started so i guess there is a daemon that knows when it was started... now i just need to know how to make it work like "uptime" except "up <program>" and make a db like "uprecords" for multiple apps.. anyone wanna do this? lol


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

#11 2006-06-11 17:00:29

kakabaratruskia
Member
From: Santiago, Chile
Registered: 2003-08-24
Posts: 596

Re: A daemon/script that records how long a program is running..

Process info is stored in /proc... I believe that's where ps gets the information.


And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.

Offline

#12 2006-06-11 17:28:26

russianpirate
Member
Registered: 2006-05-17
Posts: 161

Re: A daemon/script that records how long a program is running..

ya thats right but if i use ps or any other program every 2 sec.. its gonna lag

my dad wants me to write a kernel module oO wtf.. i dont even know c


Darkstar:
Athlon 64 3500+ (OC ~2.49ghz)
Leadtek GeForce 6800 128mb (unlocked/OC)
Rosewill Value DDR400 1GB
WDC SE 80GB
NEC 3550 DVDRW DL 16X

Offline

Board footer

Powered by FluxBB