I need a linux shell to perform a different task on each day for 4 rotating days:
Day 1: task A
Day 2: task B
Day 3: task C
Day 4: task D
And on Day 5 start again with task A and so on forever...
So I decided to use the day of the year, do a modulo 4 (division by 4 and only keep the rest) and check vs the modulo:
#!/bin/bash
let DATETEST=$(date +%j)%4
if (($DATETEST == "0" ));
then
do task A
fi
if (($DATETEST == "1" ));
then
do task B...
This worked OK until 2 days ago when I started getting the error:
let: DATETEST=009: value too great for base (error token is "009")
not sure what's wrong.
Yes: Fravadona's answer solves my problem. I also found the following note which helps and explains base10: https://stackoverflow.com/a/5455805/1829159
Chepner's comment also works for me and allowed me to discover that LET was obsolete...