I have a Bash script which should only execute in a specific time window (from midnight to 00:15 AM). But if I execute the function, I get
[: too many arguments
as an error message. How do I solve it? I still want to use Bash. I'm using Ubuntu Server 20.04 LTS.
Script:
currTime=date +%H%M
check_time_to_run() {
tempTime=$1
if [ $tempTime -gt 0 -a $tempTime -lt 015 ]; then
echo "Time is after 0 AM and before 0:10 AM. Restarting Server."
else
echo "Time is not between 0 AM and 0:15 AM. Aborting restart."
exit 1
fi
}
Asked by Niklas
(103 rep)
Dec 23, 2021, 04:17 PM
Last activity: Dec 23, 2021, 07:41 PM
Last activity: Dec 23, 2021, 07:41 PM