Skip to content

Instantly share code, notes, and snippets.

@wangyan
Created October 30, 2011 16:41
Show Gist options
  • Save wangyan/1326099 to your computer and use it in GitHub Desktop.
Save wangyan/1326099 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/local/bin/rtorrent" &
echo "."
;;
stop)
echo -n "Stopping rtorrent"
ppid=`ps ax | grep "/usr/local/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
echo "."
;;
restart)
echo -n "Restarting rtorrent"
ppid=`ps ax | grep "/usr/local/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/local/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