Skip to content

Commit 525bd0f

Browse files
authored
Adding function wait_for_backup_if_it_is_not_time_for_backup()
1 parent be684a7 commit 525bd0f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

func/main.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,3 +938,24 @@ format_aliases() {
938938
aliases=$(echo "$aliases" |tr '\n' ',' |sed -e "s/,$//")
939939
fi
940940
}
941+
942+
943+
wait_for_backup_if_it_is_not_time_for_backup() {
944+
# block backup if current hour is after 6 AM
945+
WAIT_LOOP_ENTERED=0
946+
if pgrep -x "v-backup-users" > /dev/null
947+
then
948+
hour=$(date +"%H");
949+
while [ "$hour" -gt "6" ]; do
950+
if [ "$WAIT_LOOP_ENTERED" -eq 0 ]; then
951+
# do something when enter sleeping state
952+
# $BIN/v-restart-web-backend
953+
fi
954+
WAIT_LOOP_ENTERED=1
955+
current_date_time="`date "+%Y-%m-%d %H:%M:%S"`";
956+
echo "$current_date_time - wait to backup user $user - current hour is $hour";
957+
sleep 300
958+
hour=$(date +"%H");
959+
done
960+
fi
961+
}

0 commit comments

Comments
 (0)