Welcome, guest! Login / Register - Why register?
[email protected] webmail now available. Want one? Go here.
You will not find us on Bing and you will get a bounce when you try registering with an outlook/hotmail/live email address here. And the irony is they spam us and we don't spam them. Not our fault. Blame the corporate bully. #microsoftdeez

Paste

Pasted as Bash by registered user uwe ( 10 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: