Shell script to reconnect to host
Posted: Thu Nov 05, 2015 1:58 pm
I wrote a simple script to ceck if the deluge demon is running and if not to restart it:
I added it to scheduled job on cron to make it run every 5 minutes...everything work fine, if I kill the deluge demon (deluged) my script restart it correctly.
My problem is that one:
I'm using deluge to download torrents, but sometimes it lost the connection with the localhost (127.0.0.1) and periodically I have to check if it still running, how can I improve the above code to automatically reconnect to the host?
Thanks!
Code: Select all
#!/bin/bash
if [[ $(pidof deluged | wc -1) -eq 0 ]]; then
deluged
fi
My problem is that one:
I'm using deluge to download torrents, but sometimes it lost the connection with the localhost (127.0.0.1) and periodically I have to check if it still running, how can I improve the above code to automatically reconnect to the host?
Thanks!