Skip to content

Instantly share code, notes, and snippets.

@gregology
Last active February 2, 2016 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregology/4703c1d72c0a45277125 to your computer and use it in GitHub Desktop.
Save gregology/4703c1d72c0a45277125 to your computer and use it in GitHub Desktop.
Keeping an eye on the run away Dropbox service on Ubuntu.

Dropbox Ubuntu Scripts

I was haing some trouble (OOMing and crashing) with Dropbox running on an old Ubuntu laptop so I wrote a couple of scripts to keep it in check. The first one shuts down Dropbox when a threshold load average is met (4.00). And the second one restarts the Dropbox process if it crashes.

Crontab

*/10 * * * * ~/dropbox_restarter.sh >> ~/dropbox_restarter.log
*/1 * * * * ~/dropbox_load_limiter.sh >> ~/dropbox_load_limiter.log
#!/bin/bash
loadavg=$(uptime | awk '{print $10}' | cut -d "," -f 1)
currentdate=$(date +%Y-%m-%d:%H:%M:%S)
## Optional to log disk space usage too
useddisk=$(df -h | grep ext4_2TB_1 | awk '{print $3}')
threshold=4.00
echo "$currentdate - $useddisk - $loadavg load"
thresholdbreach=$(echo "$loadavg > $threshold" | bc)
if [ $thresholdbreach = 1 ]
then
echo "load average above $threshold threshold... stoping dropbox"
dropbox stop
fi
#!/bin/bash
status=$(dropbox status)
failed_string="Dropbox isn't running!"
echo "$status"
if [ "$status" != "$failed_string" ]
then
echo "dropbox is running!!!"
else
echo "dropbox is not running... starting!!!"
dropbox start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment