Shell script to reconnect to host

Suggestions and discussion of future versions
Post Reply
Fabbio1984

Shell script to reconnect to host

Post by Fabbio1984 »

I wrote a simple script to ceck if the deluge demon is running and if not to restart it:

Code: Select all

#!/bin/bash
if [[ $(pidof deluged | wc -1) -eq 0 ]]; then
    deluged
fi
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!
Post Reply