#!/bin/sh # A tiny wrapper to let cron run jobs (like slocate) with a respect # to the system load. Written by LOAD=0.5 # -l: the default critical load value TIME=2 # -t: 1 for the very last minute, 2 => 5 min, 3 => 15 min ONCE=0 # -o: once per day while : do case $1 in -l|--load) LOAD=$2; shift; shift; continue;; -t|--time) TIME=$2; shift; shift; continue;; -o|--once) ONCE=1; shift; continue;; -h|--help) head -l 6 "$0"; exit 0;; *) break;; esac done LOAD=$(echo "100*$LOAD"|bc) LOAD=${LOAD%.*} NOW=$(echo "100*`/usr/bin/cut -f$TIME -d' ' /proc/loadavg`"|bc) NOW=${NOW%.*} [ "$(/bin/ls -l --time=use "$1"|/usr/bin/cut -c43-48)" = \ "$(/bin/date +"%b %d")" ] && exit 0 # $1 already used today # (maybe not by us :-/ ) [ $NOW -le $LOAD ] && eval $*