Check Dropbox CLI / dropbox.py status via cron / bash script
I've been using the command line (CLI) version of Dropbox on my Centos 6.5 server as an offsite backup and it has been working well, the recent 1TB storage upgrade makes this a decent backup option.
One problem I've been having is that sometimes the Dropbox process seems to die, I tried several different scripts to keep track of the status of dropbox via the dropbox.py python scripts but I eventually found this bash script to work. I've set it as an hourly cron job in /etc/cron.hourly and it's working well so far.
Basically we get the status output from dropbox.py, if it says it isn't running then we start it otherwise we output it's current status. In both cases an email is sent out to show the current status, perhaps a bit much information but I want to keep track of Dropbox and make sure that it's running consistently
Here's the BASH script, note that I have displayed one 'echo' line on three lines here to display it on the page correctly but this should all be on a single line:
STATUS=`/root/bin/dropbox.py status` echo $STATUS if [ "$STATUS" = "Dropbox isn't running!" ]; then # if no then start it... # (the following 3 lines should all be on a single line! echo "Dropbox.py was not running, trying to restart..." | mail -s "Dropbox.py was not running, trying to restart..." email@example.com echo "Dropbox.py was not running, trying to restart..." /root/bin/dropbox.py start else echo "$STATUS" | mail -s "$STATUS" firstname.lastname@example.org echo "$STATUS" fi
Obviously this is only of use to you if you have already installed the Dropbox CLI version but I'll leave that to your own Googling to find out how to do. You will also need to make sure that the correct install location of your 'dropbox.py' is referenced in the script, for me it was in '/root/bin/' but change this in the script as appropriate.
Originally published on 2015-02-24 12:14:44 by Rick Curran
Last edited on 2015-02-24 12:17:20 by Rick Curran
There are currently no Visitor Comments for this post.