I'm looking to modify a script I have to stop it running at a certain time in the day whilst my machine reboots. I've found the following suggestion which seems to fit the bill perfectly but for some reason when I run the script I get no output even though the script contains an echo command.

Stop Cron job for a particular time interval

I modified the script slight as I need it to run everyday at the same time. Thats the only change I made and whether I run it as is in the post or modified I get no output.


if [[ $(date +%H) -eq 19 ]]; then
  echo "I don't run at this time"
  exit 1
  echo "Something to do at other times here..."

My aim is to verify the script will work for me. It would appear to be working as if I run the script with bash +x test then it works I get the correct response for the time. If I simply run test however I get no output.

rohtua@rohtuas_pc:~/scripts $ test
rohtua@rohtuas_pc:~/scripts $

If someone could explain why I get no output it would be much appreciated. I have other scripts set up including the one I'm looking to ultimately modify to add the timing condition into that use the echo command to announce messages as to progress and they work no issues its just this one for some reason.


If I simply run test however I get no output.

That is because test is a builtin bash command and without arguments will just return false (with no output):

The test and [ builtins evaluate conditional expressions using a set of rules based on the number of arguments.

0 arguments The expression is false.

Source test Man Page - Linux - SS64.com

It would appear to be working as if I run the script with bash +x test

+x turns off debugging. This appears to have the side effect that bash +x test now runs your script (called test) instead of the test builtin.

The correct workaround is not to use the name of an existing command and the name of your bash script.

Some implementations of Unix (for example Cygwin) also have a test executable (/usr/bin/test) which may get executed in preference to your test script depending on how your PATH is configured:

$ which test

Further Reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.