Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Bash by registered user uwe ( 11 years ago )
#!/bin/bash

# check every x seconds
checktime=10

# what to check, needs to have exit code 0 if sigSTOP should be issued
check="lsof -Pni :8200 -sTCP:ESTABLISHED"

# what pids to sigSTOP
pids="lsof -t -c par2 -c unrar -c python -c rtmpdump -c rsync"

# paused-file
pausef="/media/crypt/dl/run/paused"

# pid-file
pidf="/media/crypt/dl/run/sigstop.pid"

# main
paused=0
while sleep "$checktime"; do
    if $check; then
        $pids | xargs kill -STOP
        paused=1
        touch "$pausef"
        continue
    fi
    if [ $paused -eq 1 ]; then
        $pids | xargs kill -CONT
        rm "$pausef"
        paused=0
    fi
done&
echo $! > "$pidf"
disown

 

Revise this Paste

Your Name: Code Language: