Ubuntu Pastebin

Paste from Val at Mon, 2 Nov 2015 14:24:11 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
USER=${USER:-$1}
PATH=${PATH:-"/usr/local/bin:/usr/bin:/bin:/home/$USER/bin"}

## [USAGE] crontab -e
## Examples:
# Run every minute * * * * *    ~/rtorrent_cron <username>
# every 10 minues  */10 * * * * ~/rtorrent_cron
# on reboot        @reboot      ~/rtorrent_cron
# hourly           @hourly      ~/rtorrent_cron

#COMMAND="dtach -n /home/$USER/rtorrent.dtach rtorrent"
#COMMAND="tmux new -s rtorrent -d rtorrent"
COMMAND="screen -dmS rtorrent rtorrent"

## Uncomment if you want to log these actions
#LOG=/home/$USER/rtorrent_cron.log
#MSG="$(date "+[%d %b %H:%M:%S]") CRON: Starting rtorrent..."

start_rtorrent() { #test if rtorrent is running, if not, start it
    if [[ -z $(pgrep -u $USER rtorrent) ]]; then
        $($COMMAND) && sleep 1
    fi
}
Download as text