Operating System - HP-UX
1848534 Members
3939 Online
104033 Solutions
New Discussion

Re: renicing a user process

 
Stevan Popovic
Occasional Contributor

renicing a user process

Hello

I would like to set a user to have the lowest priority for processing. But each time this person logs in they have this priority.

I would imagine adding the command to .profile is the best method to do this.

Thanks
6 REPLIES 6
Tomek Gryszkiewicz
Trusted Contributor

Re: renicing a user process

I didnt try it, but this is an idea:
change his shell to your script, which invokes shell with specified priority (nice something /usr/bin/sh). All the processes inherits priority from it's parents, so all user processes will be running with this priority

-Tomek
Brian Bergstrand
Honored Contributor

Re: renicing a user process

This should work from their .profile:

renice -n 19 $$

This will renice their login shell to the lowest priority, and then any task spawned from that shell should inherit the new priority, so everything they run will be at the lowest level.

Of course, by default the user can edit their .profile and remove this, so you'll want to change ownership on that and their home dir so they can change/replace their .profile.

HTH.
A. Clay Stephenson
Acclaimed Contributor

Re: renicing a user process

This is one approach:

In the user's .profile as the last entry:

exec nice -n 20 sh
If it ain't broke, I can fix that.
Vijaya Kumar_3
Respected Contributor

Re: renicing a user process

If you add this to .profile, user can change the priority, (if permissions there). So i would suggest to put in /etc/profile and /etc/csh.login...Do a if condition..

export LOGID=`whoami`

if [ $LOGID -eq "user" ]
then
do
.....whatever u do with nice
done

Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Stefan Farrelly
Honored Contributor

Re: renicing a user process

Weve done this before, but by renaming the binary or application which launches their program and replacing it with a script with the same name which instead does;

nice -10

This way whenever someone logs in it always runs their application with a lower priority.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Brian Bergstrand
Honored Contributor

Re: renicing a user process

Ooops, that should be "CAN'T change/replace their .profile."

Damn fat fingers.