From 53a732dd29a87a9a165886765fc0199f13520a91 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 12 Feb 2020 13:58:57 +0100 Subject: [PATCH] Better way to calculate threads --- README.MD | 2 +- music-sync.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.MD b/README.MD index 89b6a22..a38b1d0 100644 --- a/README.MD +++ b/README.MD @@ -18,7 +18,7 @@ Script to sync music from one folder to another -t, --temp The temporary cache for converted files (default: /tmp/converted) -c, --convert Convert files to a given bitrate in kbps before syncing (default: 192) -a, --resize-art Resize album-art before syncing (default width: 200) - -j, --jobs Number of processes to use in multi-threading (default: CPU_CORES - 2) + -j, --jobs Number of processes to use in multi-threading (default: nproc - 2) -v, --verbose <0-6> Set log level (default: 2) -h, --help Display this help text diff --git a/music-sync.sh b/music-sync.sh index 597202f..cc494b2 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -13,7 +13,7 @@ #/ -t, --temp The temporary cache for converted files (default: /tmp/converted) #/ -c, --convert Convert files to a given bitrate in kbps before syncing (default: 192) #/ -a, --resize-art Resize album-art before syncing (default width: 200) -#/ -j, --jobs Number of processes to use in multi-threading (default: CPU_CORES - 2) +#/ -j, --jobs Number of processes to use in multi-threading (default: nproc - 2) #/ -v, --verbose <0-6> Set log level (default: 2) #/ -h, --help Display this help text #/ @@ -46,7 +46,7 @@ help=false temp="/tmp/converted" convertart=false coverartsize=200 -jobcount="-2" +jobcount=$(expr $(nproc) - 2) multithread=false script_name=$(basename "${0}") script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) @@ -189,12 +189,12 @@ GetOptions() { -j|--jobs) VerboseOutput 0 "--jobs given" multithread=true - jobcount="-2" + jobcount=$(expr $(nproc) - 2) if [[ $2 != "" ]]; then jobcount=${2} fi shift 2 - VerboseOutput 1 "multithreading will use ${jobcount} threads" + VerboseOutput 1 "Multithreading will use ${jobcount} threads" ;; --) shift