--- usr.sbin/periodic/periodic.sh.orig 2007-06-22 13:04:05.000000000 +0300 +++ usr.sbin/periodic/periodic.sh 2008-12-21 12:06:09.000000000 +0200 @@ -78,7 +78,23 @@ then output=TRUE processed=$(($processed + 1)) - $file $tmp_output 2>&1 + + _script=$(basename "$file") + # trim three leading digits and dot if present + # replace '-' with '_' + _script=$(echo "${_script##[0-9][0-9][0-9].}" | tr - _) + eval _nice=\$${arg##*/}_${_script}_nice + if [ -n "${_nice}" ] + then + nice_cmd="nice -n ${_nice}" + elif [ -n "${default_nice}" ] + then + nice_cmd="nice -n ${default_nice}" + else + nice_cmd='' + fi + + $nice_cmd $file $tmp_output 2>&1 rc=$? if [ -s $tmp_output ] then --- usr.sbin/periodic/periodic.8.orig 2007-09-08 00:54:45.000000000 +0300 +++ usr.sbin/periodic/periodic.8 2008-12-21 13:19:24.000000000 +0200 @@ -144,6 +144,18 @@ If .Ao Ar basedir Ac Ns Va _output is not set or is empty, output is sent to standard output. +.Pp +If +.Ao Ar basedir Ac Ns Va _ Ns Ao Ar script Ac Ns Va _nice +variable is set, the script will be run at specified nice level. Otherwise +nice level from +.Va default_nice +variable is used. Script name should be specified without three leading digits +and dot, dashes in the script name should be replaced with underscores (e.g. +.Pa daily_status_mail_rejects_nice +variable for +.Pa /etc/periodic/daily/460.status-mail-rejects +script). .Sh ENVIRONMENT The .Nm --- etc/defaults/periodic.conf.orig 2008-01-27 10:07:14.000000000 +0200 +++ etc/defaults/periodic.conf 2008-12-21 13:26:24.000000000 +0200 @@ -22,6 +22,9 @@ # periodic script dirs local_periodic="/usr/local/etc/periodic" +# default nice level all periodic scripts will be run at +default_nice="" + # Daily options