From 6d285793b1f04ca5350ebd9511fd65f308cc5840 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 8 Apr 2019 11:09:11 +0200 Subject: [PATCH] extract date variable --- zzz_evobackup | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zzz_evobackup b/zzz_evobackup index 88e4655..7fb7181 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -78,12 +78,14 @@ pick_server() { return 1 fi + # Extract the day of month, without leading 0 (which would give an octal based number) + today=$(date +%e) # A salt is useful to randomize the starting point in the list # but stay identical each time it's called for a server (based on hostname). salt=$(hostname | cksum | cut -d' ' -f1) # Pick an integer between 0 and the length of the SERVERS list # It changes each day - item=$(( ($(date +%e) + salt + increment) % list_length )) + item=$(( (today + salt + increment) % list_length )) # cut starts counting fields at 1, not 0. field=$(( item + 1 ))