Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Great Idea!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Great Idea!
Authored by: ExecutiveEditor on Jan 19, '02 04:33:54PM

I've been using Nicer, which is a great program, but I'd rather not launch an app whenever I want to give TuxRacer a higher priority. Now, I can use this script in the Script Menu (available from Apple's Applescript page).

The script has one little problem, however: It keeps running if you choose to cancel rather than pick a process to renice. Here's my mod, which cancels the program if you hit the "Cancel" button:

tell application "Finder" to set theApps to name of every process
set theApp to (choose from list theApps OK button name "Edit Priority")
if theApp is not false then
set thePID to do shell script "ps -axww | /usr/bin/grep '[/]" & theApp & "'| awk '{print $1}' | head -1"
set newPriority to text returned of (display dialog "New priority for '" & theApp & "':" default answer "0")
Renice(newPriority, thePID, theApp)
end if
on Renice(newPriority, thePID, theApp)
try
set theConfirmation to (do shell script "renice " & newPriority & " -p " & thePID)
on error
set theConfirmation to (do shell script "renice " & newPriority & " -p " & thePID with administrator privileges)
end try
display dialog ("Changed priority of '" & (theApp as string) & "':" & return & theConfirmation) buttons {"OK"} giving up after 5
end Renice

Copy this text, paste it in Script Editor, and save.



[ Reply to This | # ]
Great Idea!
Authored by: strummer on Jan 20, '02 12:10:53AM

okay, sounds good. I tried it, I picked APP, set Priority, then got this message:

sudo: renice: command not found

any help?
cheers,
brian



[ Reply to This | # ]
where do I find renice?
Authored by: strummer on Jan 20, '02 09:58:55AM

i get error that says renice not found
any help?
cheers,
brian



[ Reply to This | # ]
where do I find renice?
Authored by: ExecutiveEditor on Jan 20, '02 01:04:28PM

Which version of OS X are you using? I think I remember something here on Mac OS X Hints that indicated nice/renice wasn't available before 10.1.



[ Reply to This | # ]
where do I find renice?
Authored by: strummer on Jan 20, '02 04:13:43PM

I have the current 10.1.2
is it part of the developer's tools?
because I haven't loaded that yet.
thanks
cheers,
brian



[ Reply to This | # ]
where do I find renice?
Authored by: ExecutiveEditor on Jan 20, '02 09:08:17PM

I wouldn't think so, but I'm not sure. I have the Developer Tools installed on both my Mac at work and the one at home, so I can't check. Sorry.



[ Reply to This | # ]
where do I find renice?
Authored by: babbage on Jan 21, '02 01:53:22PM
If you need to find where a command is, always give "which" a try first. This will give you the instance of the program that shows up first in your path (thus if you have a bunch of custom stuff in /usr/local/bin and some of it overrides default stuff in /usr/bin or /bin, then you'll get whichever version shows up first in your path:
% which renice
/usr/bin/renice
% env | grep '^PATH'
PATH=/usr/X11R6/bin:/sw/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sw/sbin:/Users/chris/bin/powerpc-apple-darwin:/Users/chris/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/X11R6/bin
% 

If I remember correctly, the nice & renice commands were installed as far back as the Public Beta, but the Darwin kernel didn't acknowledge run level change requests until 10.1. Before that you could run the command, but it didn't really do anything.

[ Reply to This | # ]

where do I find renice?
Authored by: barrysharp on Jan 21, '02 04:37:19PM

...also if one is using the Shell /bin/sh then one can use the Shell's (/bin/sh) built-in command 'type'.

Thus

> type renice
renice is: /usr/bin/renice

> type type
type is an exported alias for 'whence -v'

> whence -v renice
renice is a tracked alias for /usr/bin/renice

> whence -v type
type is a shell builtin


Mind you, type ONLY works if '/usr/bin' is defined in the PATH enviroment variable. If '/usr/bin' not defined in PATH then what you would see is

> type renice
renice not found

Hope this helps explains some additional background.

Regards... Barry Sharp



[ Reply to This | # ]
where do I find renice?
Authored by: barrysharp on Jan 20, '02 10:04:36PM

stummer:

I'm running X v10.1.2 and it's located at /usr/bin/renice.

Regards... Barry Sharp



[ Reply to This | # ]