Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Please share command to find any script which is running for more than say 30 minutes. in Linux System

share|improve this question

migrated from Jan 15 '13 at 8:50

This question came from our site for professional and enthusiast programmers.

Hi, and welcome to SO. Just so you know, you might consider asking this question at Further, this might give you some pointers:… – DWright Jan 15 '13 at 8:16
This could be helpful:… – Prakash Murthy Jan 15 '13 at 8:17

2 Answers 2

the ps command has an etimes field, that gives you the time since a given process has been started, in seconds.

the following bash script will output the PIDs of processes that have been running for longer than 30 minutes.

ps -eo etimes=,pid= | while read sec pid; do
 if [ ${sec} -gt ${SEC} ]; then
   echo ${pid}
share|improve this answer
hi @umlaute, your script gives on my box (standard Ubunut 12.04 setup) a "ERROR: Unknown user-defined format specifier "etimes"". What do I do wrong? – humanityANDpeace Jan 15 '13 at 10:22
ah yes; it seems that only newer versions (>=3.3.0) of procps (actually procps-ng) have the "etimes" field. i'm using debian/wheezy that ships with procps-3.3.3 – umläute Jan 15 '13 at 11:41

Assuming GNU date + ps, this gives you a list of pids older than 30 minutes:

# weird format to match ps -o lstart
cutoff=$(date -d '30 minutes ago' +'%a %b %e %T %Y')
ps -e -o lstart,pid |
awk '$0 < "'"$cutoff"'" {print NF}'

On linux, you can then check whether /proc/$pid/exe resolves to a known interpreter like /bin/sh, /bin/bash or /usr/bin/python - if so, you know it's a script.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.