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.rootis not needed to nice your own process.nice -n -20 matlaband this is the output nice: cannot set niceness: Permission denied. Matlab starts up and the nice value is 0.system('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 localfor parallel processing. @HaukeLaging - I am beginning to think you are right.