From d75aca2ebaadb83c1a1b9793a65d13048411dbf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 6 Sep 2016 23:39:49 +0200 Subject: Fix backup script I should have use unix time from beginning. --- config/i3blocks/scripts/backup | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/i3blocks/scripts/backup b/config/i3blocks/scripts/backup index 24b3954..bfa3d39 100755 --- a/config/i3blocks/scripts/backup +++ b/config/i3blocks/scripts/backup @@ -6,16 +6,20 @@ fi state=5 if [[ -e ~/.backup_date ]]; then - today=$(date +"%Y%m%d") - prev=$(date -d `cat ~/.backup_date` +"%Y%m%d") - dif=$(expr $today - $prev) - if [[ $dif -ge 30 ]]; then + now=$(date +"%s") + prev=$(cat ~/.backup_date) + dif=$(expr $now - $prev) + # 15 days + if [[ $dif -ge 648000 ]]; then state=4 - elif [[ $dif -ge 20 ]]; then + # 12 days + elif [[ $dif -ge 518400 ]]; then state=3 - elif [[ $dif -ge 5 ]]; then + # 5 days + elif [[ $dif -ge 216000 ]]; then state=2 - elif [[ $dif -ge 2 ]]; then + # 2 days + elif [[ $dif -ge 86400 ]]; then state=1 else state=0 -- cgit v1.2.3