I have a crontab job setup. In the crontab file, I have a path to a text file. My text file has a wget command (which in turn, executes a PHP file). If the crontab file just has the path to the text file, will it automatically bash (execute) that text file? Or do I need to prefix the path to the text file with bash?
Asked
Active
Viewed 509 times
0
-
You can try it out by copying the "command" portion of the line into a shell, and pressing return. If it says "Permission denied" or another error, then you'll need to check things as suggested by other answers. – fredden Mar 04 '10 at 20:08
1 Answers
10
If the file is executable (check if it has x in ls -l
, if not, then use chmod
to set the executable bit) and the first line contains #!/bin/bash
then it will be interpreted in bash.
The other option is, as you suggest, to pass it as an argument to bash:
/bin/bash /path/to/your/file.sh

L.R.
- 775
- 6
- 11
-
So, my script should do the following: 1stline: #!/bin/bash 2ndline: wget insertweburl here Is that correct? – StephenPAdams Mar 04 '10 at 22:23
-
1Correct. And use `chmod +x
` to set the executable bit. Also, you should probably use the full path to wget, since cronjobs usually run a "bare" environment where `$PATH` might not include the directory where the wget binary resides. – Mikael S Mar 05 '10 at 04:44