Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:throttle_process [2015/04/22 06:42] (current)
Line 1: Line 1:
 +====== Throttle background processes ======
 +Example to throttle the number of unzips running when a large number of files need to be unzipped
 +<code bash>
 +#!/bin/sh
 +cd /​data/​somefolder/​rzips
 +TARD=/​data/​somefolder/​anotherfolder
 +LOGF=/​data/​somefolder/​unziplog
 +COUNTER=0
 +for z in *.zip; do
 +  LOGFILE=$LOGF/​${z}.log
 +  CNTUNZIP=`ps -ef|grep -c unzip`
 +  while [ $CNTUNZIP -gt 51 ]; do
 +    sleep 1
 +    CNTUNZIP=`ps -ef|grep -c unzip`
 +  done
 +  let COUNTER=COUNTER+1
 +  echo "#: $COUNTER - Unzipping $z"
 +  nohup unzip $z -x LOG* -d $TARD > $LOGFILE 2>&1 &
 +done
 +</​code>​
  

QR Code
QR Code tech:linux:throttle_process (generated for current page)