how to grep the process running more than 30 days only?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Anyway,is there a way for me to just grab the day more than 30 in this case?
Also, i tried to put this into the script variable, but there is error...
example as below is nto working:
pid=ps aux | grep -w <process name>| grep -v grep | ps -o pid,etime,cmd `awk '{ print $2 }'`
Please give us the error that's being produced -- that'd help diagnose where the problem is occurring.
Plus, I'm speculating that you may be able/needing to involve the `date` command but this is pure speculation. Just show us the error you get, first.
Sasha
EDIT: looks like you're missing a pipe or a comma, before the awk command.
if i just execute the command from the shell, it is working...but when i put into the the script, it is showing the error...i think it might be related to the quote use but i just can't figured out which one
pg009> ./getoldprocess.sh
./getoldprocess.sh: line 5: { print $2 }: command not found
pg009>
i=`ps aux | grep -w run | grep -v grep | ps -o pid,etime `awk '{ print $2 }'` `
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.