1828302 Members
3025 Online
109975 Solutions
New Discussion

renice via cron

 
K.C. Chan
Trusted Contributor

renice via cron

All, I am having problem setting priority of a process to a higher value via cron job. According to the man page on renice, only root can up the priority of a process. How would I get around this? Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
9 REPLIES 9
Szilveszter Juhos
New Member

Re: renice via cron

Use sudo in crontab to change the priority. It is something like i) with visudo include cron into the sudoers file with NOPASSWD and only for the renice command ii) edit the script that is called in the crontab like:

sudo renice +1

Cheers
Szilva
K.C. Chan
Trusted Contributor

Re: renice via cron

I know sudo will work, does any one know of anthing else? I will use sudo as the last resort. Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
Szilveszter Juhos
New Member

Re: renice via cron

Rory R Hammond
Trusted Contributor

Re: renice via cron

We have 2 programs xmgen and cscomm that our developer has failed to startup up with a nice value. I created a root cron job containing the following lines and ran it Once an hour until the developer fixed the problem.
(this was using HPUX 11i.) You might have change the cut fields for other unixes.

good luck
Rory

for arg in `ps -fel |grep -e xmgen -e cscomm |grep -v grep|cut -c 15-21`
do
renice -n +20 ${arg}
done
There are a 100 ways to do things and 97 of them are right
K.C. Chan
Trusted Contributor

Re: renice via cron

All,
I've tried running the cron job under root. But still the priority did not increase. Any idea?
Reputation of a thousand years can be determined by the conduct of an hour
U.SivaKumar_2
Honored Contributor

Re: renice via cron

Hi,

Does the priority Increases when you run the command as root in the shell prompt manually ?

Try this in that Cron script

/usr/bin/snice -20

eg:

/usr/sbin/snice -20 httpd


regards,
U.SivaKumar
Innovations are made when conventions are broken
U.SivaKumar_2
Honored Contributor

Re: renice via cron

Hi,

Are you running that process as what ? root or that user ?.

regards,
U.SivaKumar
Innovations are made when conventions are broken
K.C. Chan
Trusted Contributor

Re: renice via cron

SivaKimar,
Yes when I ran it manually it works. Yes, I am running the cron job as root. Yes, I've included the full path of the command as /usr/bin/renice -19 . Any ideas why? Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
K.C. Chan
Trusted Contributor

Re: renice via cron

ALL,
I've figured it out; There was no problem running renicing priority as root via cron. It was ths script, it was checking against an environmental varialbe USER to see if root is running the script. Unfortunately this was not set in cron, this is solved when I set the USER variable in cron. Thanks all for your help.
Reputation of a thousand years can be determined by the conduct of an hour