Get process's time value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Get process's time value
# 1  
Old 06-20-2010
Get process's time value

Hi, I'm trying to learn csh so I've started to do some simple scrips.
Now I'm kinda stuck in this one: I want to do a script that first search, for each user, if there's at least a process with a TIME >= something (30 mins, for example).
There are 2 things that I cant figure out:
- in the "foreach" line, how can I specify the values that the PIDs can assume? Does
Code:
foreach pid ($PID)

work at all ?
- How can I get the time value from each process?
Thank you for your help
# 2  
Old 06-21-2010
ps command will help u in what u trying to do..
like this

Code:
ps -ef

it gives u the output with date and time.
if now u want all the process with in last somtime.

Code:
ps -ef > file

then u can use loop on file easily and inside loop can use find command for mtime.

or u can use pipe and use awk and print $5, $6 and $8 and u will have time and then u can see which 1 is bigger.
# 3  
Old 06-21-2010
Hi GarFunkel, are you learning csh because of a legacy situation? Otherwise I would advise you learn a bourne shell derivative instead, e.g. ksh.
Here are two links that discuss the problems with csh :

C shell - Wikipedia, the free encyclopedia
Csh Programming Considered Harmful
# 4  
Old 06-22-2010
Quote:
Originally Posted by dazdseg
ps command will help u in what u trying to do..
like this

Code:
ps -ef

it gives u the output with date and time.
if now u want all the process with in last somtime.

Code:
ps -ef > file

then u can use loop on file easily and inside loop can use find command for mtime.

or u can use pipe and use awk and print $5, $6 and $8 and u will have time and then u can see which 1 is bigger.
Thank you dazdseg for the help. Since I'm trying to learn the shell mechanisms I'm gonna try both right now.

Quote:
Originally Posted by Scrutinizer
are you learning csh because of a legacy situation?
Actually I'm reading some handouts that use mainly the Bourne and the C shell, that's the only reason Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

process CPU time

We are using JAVA program and strange thing is it takes 100% CPU when not in use. The program function is to stream a file on output port (one direction). It checks one directory and when there is a file in it, starts. While it is streaming the CPU usage is normal, about 20%. But, if... (9 Replies)
Discussion started by: orange47
9 Replies

2. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

3. Linux

Process start time not showing correct time

Process start time is not showing the correct time: I had started a process on Jun 17th at 23:30:00. Next day morning when I run the command "ps -ef | grep mq", the process is showing the start date of Jun 17th but the start time is 00:16:41 Day/Date is setup correctly on the server. It... (2 Replies)
Discussion started by: hemangjani
2 Replies

4. UNIX for Advanced & Expert Users

Process accounting and Shell process time

Hi All, I am running the following accounting on one of my executable, $ accton /home/myexe-acct $ ./myexe $ accton When I check the process timings I get the below result, Shell process time: 300ms myexe time: 100ms I want to know on why the shell(sh) process is taking so much time... (1 Reply)
Discussion started by: santoshbr4
1 Replies

5. Shell Programming and Scripting

Process one line at a time

Guys, I've written the following to proces one line at a time and then process individual column within the line.. But it works only when there is one line. I know awk will simply fetch multiple lines when run against a file with many lines. How do i achieve this ? cat ${PARFILE} |... (3 Replies)
Discussion started by: kamathg
3 Replies

6. UNIX for Dummies Questions & Answers

how to Decrease priority of a particular process in time of process creation

how to decrease priority of a particular process in time of process creation... and also how to decrease priority of a particular process after process creation.. can any one please help me out... (2 Replies)
Discussion started by: Ramkum
2 Replies

7. Programming

Time taken by a child process?

Hi, I have a program where I fork few child jobs and call execvp to run another jobs. I use wait to wait for any job to get complete. Requirement is I need to know the actual time taken by child job during execution. I thought of calculating the time just before forking and after wait, but... (3 Replies)
Discussion started by: anjul_thegreat
3 Replies

8. Solaris

what time did my process die ??

Hi there I have a backup script that runs every night and for some reason ive been getting in in the morning and the process has died, Is there any way I can tell when it died? if not .....would anybody recommend some scripting that i could do that would be able to tell me this information ... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

9. Programming

get process start time

Hi all, I like to know how can I get currenlty running process start time and date , I know only porcess id in solaris and hp-ux and what is command to get same using ps with switch. Thanks Naeem (1 Reply)
Discussion started by: naeem ahmad
1 Replies

10. Programming

process time

Hi , I want to find the total time taken by the system for doing a particular process. Can u help me!!!!! thanx- bye (1 Reply)
Discussion started by: sathishkumar
1 Replies
Login or Register to Ask a Question