linux - Kill processes older that one day by its name -


i have question related problem. here's code:

ps -eo pid,etime,cmd|grep ${1}|grep -v grep|awk '{if ($2>="23:59:59") print $1}'|xargs kill -9 

i trying kill processes specific name etime more day. worked way until told script cannot kill processes represent date in format like: 1-23:00:00.

changing variable $2 in awk procedure 1-00:00:00 kills processes given name. can give me hint how format etime properly?

instead of changing awk script, suggest changing ps option etime etimes.

with etimes got lifetime in seconds. free choose kill or not kill if value > or < value. even, $2>=somevalue1 && $2<= somevalue2


Comments