Page 1 of 1

(RESOLVED) BASH scripts for automation

Posted: Fri Mar 12, 2021 12:22 am
by Whatheway
Good evening everyone,

I am following a tutorial online for setting up the WPS/WRF and I would like to automate the process some in a script.
I am trying to write a IF/ELSE statement that will look at the UTC time on my desktop and round down to the nearest run.

This is what I have come up with but I can't see to get it to run.

Any help would be great!

#!/bin/bash

UTC_TIME= if [`date +%H -u` -ge 0] && [`date +%H -u` -lt 5]
then UTC_TIME=0
elif [`date +%H -u` -ge 6] && [`date +%H -u` -lt 11]
then UTC_TIME=6
elif [`date +%H -u` -ge 12] && [`date +%H -u` -lt 17]
then UTC_TIME=12
else [`date +%H -u` -ge 18] && [`date +%H -u` -lt 23]
UTC_TIME=18
fi

echo $UTC_TIME

Re: BASH scripts for automation

Posted: Mon Mar 15, 2021 5:12 pm
by kwerner
Hi,
Unfortunately the wrf support team does not have the resources to support scripting that isn't part of the WRF code, but hopefully someone in the community will be able to provide some tips!

Re: BASH scripts for automation

Posted: Mon Mar 15, 2021 10:38 pm
by Whatheway
RESOLVED:

hour=`date +%H -u`

if [[ $hour -ge 00 && $hour -le 05 ]]; then
STARTHOUR=00
fi

if [[ $hour -ge 06 && $hour -le 11 ]]; then
STARTHOUR=06
fi

if [[ $hour -ge 12 && $hour -le 17 ]]; then
STARTHOUR=12
fi

if [[ $hour -ge 18 && $hour -le 23 ]]; then
STARTHOUR=18
fi

Re: BASH scripts for automation

Posted: Thu Mar 18, 2021 7:13 pm
by kwerner
Thank you for updating this - hopefully it will help out someone else in the future!