Multiple scripts that are useful but don't deserve their own repository.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
multiple_scripts/lowload.sh

37 lines
956 B

#!/bin/bash
##############################################################################
#
# lowload.sh
# Get the functionality of atd and task-spooler together
# (c) Steven Saus 2021
# Licensed under the MIT license
#
##############################################################################
# first var is command to run
# second var is for task-spooler/process label
AllVars="${@}"
FirstVar="${1}"
SecondVar="${2}"
Binary=$(which tsp)
if [ -f "/tmp/${SecondVar}" ]; then
echo "Process ${SecondVar} still waiting to execute from last run" >&2
exit 99
fi
touch "/tmp/${SecondVar}"
MyLoad=$(cat /proc/loadavg | awk '{print $1}')
while [[ "$MyLoad" > 2 ]];do ####EDIT THIS LINE FOR LOAD CHANGES
echo "Waiting for load to drop below 2"
sleep 20s
echo "."
MyLoad=$(cat /proc/loadavg | awk '{print $1}')
done
rm "/tmp/${SecondVar}"
tsp -L "${SecondVar}" -d "${FirstVar}"