Print only processes running for more than 24 hours


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print only processes running for more than 24 hours
# 8  
Old 09-06-2013
@jotne,

can you please make me understand your awk part, it is not working for me. Below is out of command.

Code:
command

ps -eo pid,pcpu,pmem,user,args,etime,cmd --sort=start_time

Code:
PID %CPU %MEM USER     COMMAND                         ELAPSED CMD
    1  0.0  0.0 root     /usr/lib/systemd/systemd       20:00:42 /usr/lib/systemd/systemd
    2  0.0  0.0 root     [kthreadd]                     20:00:42 [kthreadd]
    3  0.0  0.0 root     [ksoftirqd/0]                  20:00:42 [ksoftirqd/0]
    6  0.0  0.0 root     [migration/0]                  20:00:42 [migration/0]
    7  0.0  0.0 root     [watchdog/0]                   20:00:42 [watchdog/0]
    8  0.0  0.0 root     [migration/1]                  20:00:42 [migration/1]
   10  0.0  0.0 root     [ksoftirqd/1]                  20:00:42 [ksoftirqd/1]
   12  0.0  0.0 root     [watchdog/1]                   20:00:42 [watchdog/1]
   13  0.0  0.0 root     [cpuset]                       20:00:42 [cpuset]
   14  0.0  0.0 root     [khelper]                      20:00:42 [khelper]
   15  0.0  0.0 root     [kdevtmpfs]                    20:00:42 [kdevtmpfs]
   16  0.0  0.0 root     [netns]                        20:00:42 [netns]
   17  0.0  0.0 root     [sync_supers]                  20:00:42 [sync_supers]
   18  0.0  0.0 root     [bdi-default]                  20:00:42 [bdi-default]
   19  0.0  0.0 root     [kintegrityd]                  20:00:42 [kintegrityd]
   20  0.0  0.0 root     [kblockd]                      20:00:42 [kblockd]
   21  0.0  0.0 root     [ata_sff]                      20:00:42 [ata_sff]
   22  0.0  0.0 root     [khubd]                        20:00:42 [khubd]
   23  0.0  0.0 root     [md]                           20:00:42 [md]
   26  0.0  0.0 root     [kswapd0]                      20:00:42 [kswapd0]
   27  0.0  0.0 root     [ksmd]                         20:00:42 [ksmd]
   28  0.0  0.0 root     [khugepaged]                   20:00:42 [khugepaged]
   29  0.0  0.0 root     [fsnotify_mark]                20:00:42 [fsnotify_mark]
   30  0.0  0.0 root     [crypto]                       20:00:42 [crypto]
   36  0.0  0.0 root     [kthrotld]                     20:00:42 [kthrotld]
   45  0.0  0.0 root     [scsi_eh_0]                    20:00:42 [scsi_eh_0]
   46  0.0  0.0 root     [scsi_eh_1]                    20:00:42 [scsi_eh_1]
   47  0.0  0.0 root     [scsi_eh_2]                    20:00:42 [scsi_eh_2]
   48  0.0  0.0 root     [scsi_eh_3]                    20:00:42 [scsi_eh_3]
   49  0.0  0.0 root     [scsi_eh_4]                    20:00:42 [scsi_eh_4]
   50  0.0  0.0 root     [scsi_eh_5]                    20:00:42 [scsi_eh_5]
   53  0.0  0.0 root     [kworker/u:4]                  20:00:42 [kworker/u:4]
   56  0.0  0.0 root     [kpsmoused]                    20:00:42 [kpsmoused]

# 9  
Old 09-06-2013
I would drop "cmd" from the format since it adds nothing not already provided by "args", leaving "etime" as the last field, which makes it easier to extract.

Regards,
Alister
# 10  
Old 09-07-2013
This should work, but since none of your test data are more then 20 hour, it will output none.
Code:
ps -eo pid,pcpu,pmem,user,args,etime,cmd --sort=start_time | awk 'substr($0,57,2)+substr($0,54,2)*60>24'

You may tweak toe numbers to get correct result.

Last edited by Jotne; 09-07-2013 at 04:39 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check the processes running longer than 2 hours.?

HI can someone help me to check the process running more than 2 hours. I have the below command which shows the time and process id, however, I only need the processes running more than 2 hours. (8 Replies)
Discussion started by: Vinod
8 Replies

2. UNIX for Beginners Questions & Answers

How to display processes which have been running for more than a X hours?

Hi, Is it possible to display processes which have been running for more than a 5hrs using a variation of the ps -ef command? Regards, Manny (5 Replies)
Discussion started by: mantas44
5 Replies

3. Shell Programming and Scripting

Can anyone help me to print UNIX epoch time to days,hours,min,sec ?

I have unix epoch time 1441678454803, Can you please help me to print this time in below format ? DAY,HOUR,MIN,SEC Appreciate your help!!! Thanks, Prince (7 Replies)
Discussion started by: prince1987
7 Replies

4. UNIX for Dummies Questions & Answers

At command not running out of hours

Hi All, new to the forum and new to Unix but I have an issue which is annoying on a new level. I have included a short and full version for anyone needing more information. Short Version I am running a set of scripts that work and run fine. one of the scripts arranges the first... (4 Replies)
Discussion started by: Delboy4000
4 Replies

5. UNIX for Dummies Questions & Answers

find the no of processes that ran 2 hours before or earlier

Is there a way to find out the total no of processes that were running ? - 2 or 3 hours before - list those no of processes (3 Replies)
Discussion started by: jansat
3 Replies

6. Shell Programming and Scripting

List of Running Jobs In Last 4 Hours

Hi Experts, Please help me in this. I am trying this code on AIX 5.3. I need list of jobs that executed in last 4 hours. I have a schedule on this script - cron executes it and sends mail to me for every 2 hours. I have a Job time and have around 100 jobs those execute daily. What all i need... (2 Replies)
Discussion started by: rajubollas
2 Replies

7. Shell Programming and Scripting

Capture the running process for 2 hours

Hi, How can i capture the running process for 2 hours. Thanks in advance.:b: (1 Reply)
Discussion started by: sarathkumar
1 Replies

8. Shell Programming and Scripting

Capture running process or 2 hours with an interval of 10 sec

Hi, Can any one help me on this. How to capture the running process for two hours with an interval of 10 sec. Thanks in andvance (1 Reply)
Discussion started by: sarathkumar
1 Replies

9. UNIX for Dummies Questions & Answers

Capture running process for 2 hours with an interval of 10 sec

Hi, Can any one help me on this. How to capture the running process for two hours with an interval of 10 sec. Thanks in andvance Double post, continued here, thread closed (0 Replies)
Discussion started by: sarathkumar
0 Replies

10. UNIX for Dummies Questions & Answers

How do you print the number of processes that each user is currently running in Unix?

Ok, so I know there's a way to do this, but I've been trying to find out all afternoon with no luck. I think it should print out something like this: 1 bin 2 daemon 6 duo Where the numbers on the left are the number of processes being run by the user whose name is listed on the right. Is... (4 Replies)
Discussion started by: Duo11
4 Replies
Login or Register to Ask a Question