From 5899aef982ec4f2e4aa45d050d48c1d93e93443c Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 2 Feb 2022 18:39:09 +0100 Subject: [PATCH] check_webservice_load.sh: no delay if running in an terminal. --- check_webservice_load.sh | 50 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/check_webservice_load.sh b/check_webservice_load.sh index 7baad77..8346b58 100755 --- a/check_webservice_load.sh +++ b/check_webservice_load.sh @@ -138,6 +138,25 @@ trim() { } +#--------------------------------------- +#----------------------------- +# Check some prerequisites +#----------------------------- +#--------------------------------------- + +if [[ -t 1 ]] ; then + terminal=true + LOGGING=true +else + terminal=false + LOGGING=false +fi + +# - Detect linux distribution +# - +detect_os + + # ------------- # --- Read Configurations from $conf_file # ------------- @@ -171,9 +190,13 @@ if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then # - This only makes sense if a fixed LOCK directory is used, otherwise the process list # - (and NOT the LOCK-directory) is used to look for scripts running in parallel. # - - if [[ "$LOCK_DIR" = "/tmp/${script_name%%.*}.LOCK" ]]; then - _shift="$(( $RANDOM % 10 + 1 ))" - sleep $(( $RANDOM % 25 + $_shift )) + # - Skip delay if running in an terminal (from copnsole) + # - + if ! $terminal ; then + if [[ "$LOCK_DIR" = "/tmp/${script_name%%.*}.LOCK" ]]; then + _shift="$(( $RANDOM % 10 + 1 ))" + sleep $(( $RANDOM % 25 + $_shift )) + fi fi _stop_running=false @@ -256,29 +279,10 @@ fi #trap 'rm -rf "$LOCK_DIR"' 0 2 15 -#--------------------------------------- -#----------------------------- -# Check some prerequisites -#----------------------------- -#--------------------------------------- - -if [[ -t 1 ]] ; then - terminal=true - LOGGING=true -else - terminal=false - LOGGING=false -fi - -# - Detect linux distribution -# - -detect_os - - #--------------------------------------- #----------------------------- -# Check some prerequisites +# Check some further prerequisites #----------------------------- #---------------------------------------