Skip to main content
edited body
Source Link
Niklas
  • 103
  • 4

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 0150 -a $tempTime -lt 0015 ]; 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 } 

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 015 -a $tempTime -lt 0 ]; 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 } 

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 } 
edited body
Source Link
Niklas
  • 103
  • 4

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='datecurrTime=`date +%H%M'+%H%M` check_time_to_run() { tempTime=$1 if [ $tempTime -gt 015 -a $tempTime -lt 0 ]; 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 } 

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 015 -a $tempTime -lt 0 ]; 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 } 

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 015 -a $tempTime -lt 0 ]; 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 } 
edited body
Source Link
Niklas
  • 103
  • 4

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 +%k%M'+%H%M' check_time_to_run() { tempTime=$1 if [ $tempTime -gt 015 -a $tempTime -lt 0 ]; 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 } 

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 +%k%M' check_time_to_run() { tempTime=$1 if [ $tempTime -gt 015 -a $tempTime -lt 0 ]; 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 } 

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 015 -a $tempTime -lt 0 ]; 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 } 
Source Link
Niklas
  • 103
  • 4
Loading