I am facing an issue with a bash script that I am writing. I am pretty new to bash scripts so I would be glad for some help or inputs.
We are running an Appliance Server. Unfortunately, I am not allowed to change the timezone of this server. So I need to work with the UTC Timezone.
Now I wanted to create script that should run automatically in our maintenance window at 8 PM. Now the problem is, that UTC does not know the difference between summer / winter time.
So I tried the following:
#!/bin/bash
array_time=("Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct")
ZONE=`date | cut -c 5-7`
echo $ZONE
if [[ " ${array_time[@]} " == " ${ZONE} " ]]; then
echo "SUMMERTIME CRONJOB"
else
echo "WINTERTIME CRONJOB"
fi
But for some reason, this is the output:
./test.sh
Jul
WINTERTIME CRONJOB
So even when the value Jul is part of the array_time variable, it goes to the else part of the if condition. I am not sure why this is happening. Anyone got an idea why? Or maybe anyone got a better idea how to solve this?
Thanks for your help
cheers