Another possible option (simple, but less secure) is to enable setuid/setgid permission for nice
executable.
sudo chmod +s /usr/bin/nice
setuid assign any user who can execute the file the effective UID of the file owner's (in this case root
) when executing the file, thus is equivalent as running as that user. setguid does the same for effective GID.
Or you can do it more securely:
# create a system group named `nice'
groupadd -r nice
# set the owner group for `nice' executable
chgrp nice /usr/bin/nice
# disallow other users to run `nice`
chmod o-x /usr/bin/nice
# allow anyone who are able to execute the file gain a setuid as root
chmod u+s /usr/bin/nice
# add your user to the group
usermod -a -G nice <your-user-name>
Beware you need to re-login your account for new group to take effect.
sudo
.root
is not needed to nice your own process. – jordanm Apr 18 '13 at 19:45nice -n -20 matlab
and this is the output nice: cannot set niceness: Permission denied. Matlab starts up and the nice value is 0. – Lord Loh. Apr 18 '13 at 23:51system('sudo renice ...')
in MATLAB, but matlab starts 2 processes - MATLAB and matlab_helper. I might have to do it on both. moreover I also want all my MATLAB processes to be of high priority - when I startmatlabpool local
for parallel processing.@HaukeLaging - I am beginning to think you are right.
– Lord Loh. Apr 18 '13 at 23:55htop
access to. – 41754 Jul 22 '14 at 12:02