Skip to content

Instantly share code, notes, and snippets.

@xiaochun-z
Forked from wangyan/rtorrent.sh
Last active May 14, 2017 08:34
Show Gist options
  • Save xiaochun-z/ef6746d89d46243ad3be8d30baf9b822 to your computer and use it in GitHub Desktop.
Save xiaochun-z/ef6746d89d46243ad3be8d30baf9b822 to your computer and use it in GitHub Desktop.
rtorrent satart shell script
#!/bin/sh
case "$1" in
start)
echo -n "Starting rtorrent"
su - root -c "screen -A -m -d -S rtorrent /usr/bin/rtorrent" &
echo "."
;;
stop)
echo -n "Stopping rtorrent"
ppid=`ps ax | grep "/usr/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
echo "."
;;
restart)
echo -n "Restarting rtorrent"
ppid=`ps ax | grep "/usr/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
sleep 1
su - root -c "screen -A -m -d -S rtorrent /usr/bin/rtorrent" &
echo "."
;;
*)
echo "Usage: {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment