Process running time by taking user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process running time by taking user input
# 1  
Old 03-27-2013
Code Process running time by taking user input

Need help in scripting . Below is the situation and need your inputs

Checking all the processes, scripts running time based on user input time . Below Example

Code:
ps -aef -o user,pid,etime,stime,args| grep sleep
  <user> 28995       01:24 14:14:39 sleep 120
  <user> 29385       00:52 14:15:10 sleep 1000
  <user> 29415       00:48 14:15:14 sleep 2000

Code:
#./process_check.sh  20   # scriptname minutes 
<user> 28995       20:24 14:34:39 sleep 120

(display all process,script running 20 minutes

Thank you for your help
# 2  
Old 03-27-2013
Do you mean the user sets the criteria for filtering by run time? Sounds like a good perl DateTime::Format::Strptime - search.cpan.org or awk http://www.gnu.org/software/gawk/man...Functions.html thing, where you can parse the time to filter. As I am a ksh guy not on LINUX usually, I wrote a C command tm2tm that does all sorts of time input strptime(3) - Linux man page, delta and output http://linux.die.net/man/3/strftime available here: https://www.unix.com/shell-programmin...bsd-linux.html
# 3  
Old 03-29-2013
Code

Would you be able to help me in getting

List of all processes running more that 30 mintures.
# 4  
Old 03-29-2013
We have discussed similar topic in your previous thread

Where are you stuck now?
# 5  
Old 03-29-2013
Try this
Code:
ps -eaf -o user,pid,etime,stime,args | awk 'NR>1{n=split($3,t,/:/);if(n==3||t[1]>=30){print}} '

--ahamed
# 6  
Old 04-02-2013
Thank you Ahamed It works . Thank you
# 7  
Old 04-05-2013
Seems simple:
Code:
$ ps -efx | grep -v '^.\{41\} [ 1-2][0-9]:[0-5][0-9] ' | pg
     UID   PID  PPID  C    STIME TTY       TIME COMMAND
    root     3     0  3  Feb 16  ?        285:57 statdaemon
    root   486     1 10  Feb 16  ?        1386:01 /usr/sbin/syncer
    root    40     0  0  Feb 16  ?        103:51 vxfsd
    root  1861  1443  0  Feb 16  ?        80:01 diaglogd
    root   617   616  0  Feb 16  ?        38:28 /usr/sbin/netfmt -C -F -f /var/adm/nettl.LOG00 -c /var/adm/conslog.opts
    root   750     1  0  Feb 16  ?        138:56 /opt/quest/sbin/vasd -p /var/opt/quest/vas/vasd/.vasd.pid
    root  1600     1  0  Feb 16  ?        90:44 /opt/perf/bin/scopeux
 
 .
 .
 .
 .

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get how much time process has been running in seconds

I use this command to get the time elapsed for a process ps -eo pid,pcpu,pmem,user,args,etime,cmd --sort=start_time | grep perl It gives in format 19990 0.0 0.0 user /usr/bin/php 5-09:58:51 /usr/bin/php I need in seconds. Please use CODE tags for sample input and output as well... (2 Replies)
Discussion started by: anil510
2 Replies

2. Shell Programming and Scripting

Bash Question: HowTo Exit Script with User Input While Process is Running Mid-Loop?

Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
Discussion started by: hilltop_yodeler
9 Replies

3. Shell Programming and Scripting

Process running more than require time

Frineds I need assistance in writing a script . Newbie to scripting. How to find list of processes that are running more than an hour . Below i used the step to get the etime and stime . Now by getting the result i need to display longer time process with full listing. ps -aef -o... (10 Replies)
Discussion started by: ajayram_arya
10 Replies

4. Shell Programming and Scripting

Help with kill a specific process after certain running time

Hi, Do anybody experience to write a bash script in order to kill a specific process (java) after certain time of running? eg. java java.jar task_run.txt I will run a java program (java.jar) which will run a long list of process (task_run.txt) one by one. I plan to terminate the java... (5 Replies)
Discussion started by: perl_beginner
5 Replies

5. Shell Programming and Scripting

Taking one input at a time

Legends, Please help me to come out of the below Bermuda triangle. I have four inputs in a shell script: A B C D Now, If A is passed by user then, B C D will be ignored. If C is passed by user, then A B D will be ignored. Regards, Sandy (11 Replies)
Discussion started by: sdosanjh
11 Replies

6. Shell Programming and Scripting

Running a process based on time

Hello All, My script is nearly complete, there is just one last piece that needs to be added in. I need to check for the time, and if it is lets say for example. Sunday at 5:00AM, my script cannot run. I would assume it would be something like this, parden the terrible pseudocode ... (7 Replies)
Discussion started by: jeffs42885
7 Replies

7. UNIX for Dummies Questions & Answers

how to get start time of a running process

I am trying to see if a process is running what was its start time. here is the code that I am using if then echo 'Gateway output processing started.' else VAR=$(ps -ef | grep batch_output_x ) ... fi now the problem i see is when the process is running i get two... (3 Replies)
Discussion started by: akabir77
3 Replies

8. Shell Programming and Scripting

Problem while taking input from User

Hi All, I am facing a problem while taking input from user in Shell Script. Basically , I want to read a file line by line. And I want to remove certain lines of that file.But before removing those lines , I need to ask the user whether user wants to remove the lines. If user inputs "Yes" , the... (3 Replies)
Discussion started by: swapnil.nawale
3 Replies

9. Red Hat

login process taking a long time

I'm having a bit of a login performance issue.. wondering if anyone has any ideas where I might look. Here's the scenario... Linux Red Hat ES 4 update 5 regardless of where I login from (ssh or on the text console) after providing the password the system seems to pause for between 30... (4 Replies)
Discussion started by: retlaw
4 Replies

10. Shell Programming and Scripting

keeping 10 process running at the same time

Hi guys, I neet to run sqlldr to charge about 50,000 files every day to my DWH, so I need to make an script to keep about 100 processes of sqlldr running at the same time. So, the issue is that i've been trying for a few days to make an script which can keep that amount of processes running, so... (2 Replies)
Discussion started by: razziel
2 Replies
Login or Register to Ask a Question