Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
My lpd printing seems to be running my CPU high and I want to put together a script to search and destroy, so to speak.
so far I have:
sar -u 2 5 |awk '{print $5}' # if this outputs a 0 that means the cup is running very hard
if [ $status = 0 ]
then
ps -ef |grep lpd |awk '{print $3}'
$status = 1
kill -9 |awk '{print $2}'
when |awk '{print $3}' = 1
else
do nothing
fi
# What I am looking for, When - sar -u 2 5 |awk '{print $5}' comes out with 0 I want to then run ps -ef |grep lpd |awk '{print $3}' and if this displays a 1 I want to kill process number before the 1 in the same row just different column:
I am not sure I follow your logic? When PPID is 1 this means that it was kicked off as part of your init processes. So I would expect times and so on to be large as it has been running since
your machine started. Are you really sure this should be killed and in a way that does not seem to stop the service that created it??
You may want to indicate actual code and pseudo code as some of what you have written will not work at all as displayed.
Also, please use [code][/code] tags around code and data to make it more legible and preserve formatting.
Lastly, grep is not required if awk is being used as it can already do regex matching.
For some reason printing has just stopped in my office for printers that are connected to this server (Linux). I have to run the command /usr/lib/lpd for the printers to start printing again, but I can not leave this command running because it puts the CPU to full capacity. So I have to kill the process and I check to make sure the CPU is not running hard. (sar -u 2 5)
Do you have any idea what might be causing this to happen. If I have to print a lot but not all at once I have to keep running the command and killing the process so my CPU is not running hard, other wise I get an E-mail from my VM Serve Tech telling me that my CPU us running to hard.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.