Kill processes older than a specified amount of time

From Cfwiki

Jump to: navigation, search

Housekeeping for old processess

The Netbackup client has the nasty habit of leaving bpbkar processes around after failed backups. It just spawns new ones the next time. Here is a process stanza that cleans up all of those if they are a day old. For this to work your version of ps needs to support this : "ps -eo user,pid,comm,etime"

 SetOptionString "-eo user,pid,comm,etime"
 "1-[0-9]{2}:[0-9]{2}:[0-9]{2}$"
 include=bpbkar
 signal=kill
 action=signal
 inform=true

The trick is to use the 'etime' option for 'ps' to find out how long a process has been running and then use the regular expression to match everything from

1-00:00:00 to 1-23:59:59

You can now adjust the regex to your liking. DON'T forget the "pid" option for ps , otherwise the agent can't send any signal to the process !

--stucky 11/29/07

Personal tools