Results 1 to 3 of 3
I've got a script that I run as a cron job, and I'd like to drop its priority using "nice". Can I just call the entire script with "nice", or ...
- 06-24-2007 #1
Using "nice" on a script
I've got a script that I run as a cron job, and I'd like to drop its priority using "nice". Can I just call the entire script with "nice", or should I edit the script to call each of its internal functions with nice?
In other words,Then just call /usr/loca/sbin/sysupdate.sh normally, or remove all the "nice" statements in the script and call it like this,Code:less /usr/local/sbin/sysupdate.sh #!/bin/bash nice /usr/bin/emerge --sync nice /usr/bin/emerge -uDN --world
Code:nice /usr/local/sbin/sysupdate.sh
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 06-24-2007 #2You don't need the nice statements within the script (assuming you want the script and all its children processes to have the same nice value). The children will inherit niceness from the parent.
Originally Posted by smolloy
Example:
As demonstrated here, both the parent and child have the same nice value of 12.Code:[ceyan@troy ~]$ cat some-script.bash #!/bin/bash ./some-child.bash & sleep 100 exit 0 [ceyan@troy ~]$ cat some-child.bash #!/bin/bash sleep 100 exit 0 [ceyan@troy ~]$ nice -n 12 ./some-script.bash & [1] 22949 [ceyan@troy ~]$ ps -eo pid,comm,ni | head -1 && ps -eo pid,comm,ni | grep 'some-' PID COMMAND NI 22949 some-script.bas 12 22950 some-child.bash 12
- 06-24-2007 #3
Thanks anomie. Calling the entire script with "nice" will give all child functions the same nice value, just as I want.
Thanks.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode


Reply With Quote