How would I write a script that terminates all processes owned by the current user whose machine time (TIME
column in ps
output, which I believe is the CPU time) is greater than 1 minute?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community
init
process?sleep 90
will consume almost no cpu time, but will run for more than a minute. In general you probably want to runps
with a custom output format and then parse that output, maybe withawk
to select the processes and then feed that tokill
.ps xhopid,times | awk '$2 > 60 {print $1}' | xargs -r kill