From 6a9b40f9f35efb8cc8b6507dc8d03c2246d5718a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 23:02:36 +0100 Subject: [PATCH] every rtorrent process cpulimit --- home.admin/50torrentHDD.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index ffac19440..f4750503e 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -162,14 +162,26 @@ if [ "$1" == "backup-torrent-hosting" ]; then sudo sed -i "s/^backupTorrentSeeding=.*/backupTorrentSeeding=on/g" /mnt/hdd/raspiblitz.conf fi - # set the torrents processes to cpulimit 20% - sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)" - sudo cpulimit -p ${sessionPID} -l 25 & - sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" - sudo cpulimit -p ${sessionPID} -l 25 & + # set the torrents processes to cpulimit 25% sleep 6 + echo "" + rtorrentPIDs=$(ps axf | grep "rtorrent" | awk '{$1=$1;print}' | cut -d' ' -f1) + while read -r pid ; do + ps ${pid} | grep "rtorrent" + echo "---> reducing this rTorrent process to 25% CPU" + sudo cpulimit -p ${pid} -l 25 & + echo "" + done < <(echo "${rtorrentPIDs}") + sleep 6 + + # set the torrents processes to cpulimit 20% + #sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) + #echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)" + #sudo cpulimit -p ${sessionPID} -l 25 & + #sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) + #echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" + #sudo cpulimit -p ${sessionPID} -l 25 & + echo "Done BACKUP TORRENT HOSTING" exit fi