You should check your logs to find out what might be causing the crash because that is not certainly normal behavior. It could either be a bad torrent or a bad RPC call from ruTorrent that’s bringing it down.
As for this script, we don’t use cron. rtorrent is controlled by systemd. You can easily have the service restart on failure by editing the service if you like.
sudo nano /etc/systemd/system/[email protected]
at the bottom of the middle section add
Restart=on-failure
Like so:
[Service]
Type=forking
KillMode=none
User=%I
ExecStartPre=-/bin/rm -f /home/%I/.sessions/rtorrent.lock
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent
WorkingDirectory=/home/%I/
Restart=on-failure
When done, save and exit.
sudo systemctl daemon-reload
To reload the services and then restart any rtorrent services you have.