0

I have a bash script called "myScript.bash" with:

#!/bin/bash

( sleep 30 && /usr/local/bin/php /home/scripts/misc/code.php ) &
( sleep 60 && /usr/local/bin/php /home/scripts/misc/code.php )

I then do the following to make the bash script executable:

chmod +x /usr/local/bin/myScript.bash

It should run "code.php" every 30 seconds when I enter the following in the CLI:

myScript.bash

Instead, I get:

-bash: myScript.bash: command not found.

What am I doing wrong?

2
  • yes. Even if I run it with the full directory I still get the error – GTS Joe Jul 1 '19 at 21:11
  • What does ls -l /usr/local/bin/myScript.bash say? – SHawarden Jul 1 '19 at 21:21
1

Most likely means that your current working directory isn't in the PATH (and that's a good thing).

Try:

./myScript.bash
1

If you want to run a script you have made executable, you have to write the entire path to run it, i.e.

/path/to/script

If you only write

script

bash will search in PATH a file called script. Roughly, PATH is a list of directories where bash will search automatically files. Try

echo $PATH

If you open the terminal in the directory where script is, you may also write

./script

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.