Welcome, guest! Login / Register - Why register?
[email protected] webmail now available. Want one? Go here.
Windows getting boring or just want to try something Open Source for your next Desktop Environment?! Go Zorin OS.

Paste

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