Solved

Bash script

Posted on 2011-02-26
2
440 Views
Last Modified: 2012-05-11
Hi Group

I am trying to write a bash script that will run every 30 minutes in cron that will search for all process`s owned by user bob and renice them to the value of 10.

I seem to have the logic of the script but I am unable to glue things together.

1. Firstly we need to obviously get the process`s owned by user bob - so something like ps aux | grep bob - this will gives us all the process owned by bob

2. We then need to return the process id for every process owned by bob and set the niceness to 10.  So am thinking we need to use something like the cut command to return the pid column

3. We will probably need a loop to iterate through every process id and set the nicessness to 10 using the "renice -n 10 PID"

I have the logic but am unable to put it together. Any help would be really appreciated.

Thanks.
0
Comment
Question by:tuxracer
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
Comment Utility
Assuming your system, you can do

pgrep -u bob | xargs renice -n 10

Open in new window


if you don't have renice

ps -u bob | awk '/[0-9]/ {print $1}' | xargs renice -n 10

Open in new window

0
 

Author Closing Comment

by:tuxracer
Comment Utility
Hi Tintin

Excellent! I sometimes just think too deep and get carried away with the actual result....

Thank you so much for your help.

Much appreciate!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now