Date: Sun, 21 Dec 2008 11:39:36 GMT From: Artem Naluzhnyy <tut@nhamon.com.ua> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/129814: [patch] support of per script nice(1) value in periodic.conf(5) Message-ID: <200812211139.mBLBdadv013252@www.freebsd.org> Resent-Message-ID: <200812211140.mBLBe4re067418@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 129814 >Category: bin >Synopsis: [patch] support of per script nice(1) value in periodic.conf(5) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Dec 21 11:40:03 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Artem Naluzhnyy >Release: 7.1-PRERELEASE >Organization: >Environment: >Description: The patch adds support of per periodic(8) script nice(1) value the script will be run at. There are two features: * default_nice variable - default nice level * <basename>_<script>_nice variables - nice level for the specific script Default behavior after the patch application is still the same - no nice level changes. periodic.conf(5) example: default_nice=10 daily_status_mail_rejects_enable="YES" daily_status_mail_rejects_nice=8 >How-To-Repeat: >Fix: --- 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 </dev/null >$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 </dev/null >$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 >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812211139.mBLBdadv013252>