How to get list of dates from an output of
ps command to only show those processes beyond 30 days?
My goal is to kill these processes. I can easily do this by
killall -u user --older-than 1M
But we have an outdated version of that command to which
--older-than is not available so I'm force to find another way.
One thing I'm thinking is to pass the list of processes to kill command but I couldn't figure it out how to only get the processes that are 30 days old and beyond.
If there's something like this:
ps --no-header -u username --sort=start_time -o user,pid,lstart | #get all processes beyond 30 days old | while read -r pid; do kill $pid; done
Edit: We're using procps version 3.2.8