Skip to content

Instantly share code, notes, and snippets.

@vitaly-zdanevich
Last active March 9, 2016 08:00
Show Gist options
  • Save vitaly-zdanevich/06551ee335bfde24049c to your computer and use it in GitHub Desktop.
Save vitaly-zdanevich/06551ee335bfde24049c to your computer and use it in GitHub Desktop.
call this every hour - and will do some action if for hour uploaded less than 4 gb. I wrote this script for restarting git-lfs push that stopped uploading after a few hours
#!/bin/bash
# running by cron every hour; get currently uploaded value and compare with uploaded value hour ago (readed from file),
# if delta is less then 4 gb - make something
# at the end - write currentry uploaded value to the file
prev=$(cat "./TX.txt")
now=$(ip -s link ls eth1 | awk 'NR==6{print $1}')
delta=$((now - prev))
delta=$((delta / 1000 / 1000 / 1000))
echo "$(date): delta (uploaded for last hour): $delta"
if ((delta < 4)); # gb | start screen in detached mode
then kill -9 $(pgrep screen) && cd /home/vitaly/Desktop/dk-dance/ && screen -d -m git push -u origin --all
fi
ip -s link ls eth1 | awk 'NR==6{print $1}' > TX.txt # line 6 word 1 > write to file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment