Why is crontab giving "No such file or directory" error when the file DOES exist?
You are trying to execute a script which does not have a valid shebang.
Add the shebang as the first line of the script like this (adjust path of course):
#!/usr/bin/php
Or change the crontab entry to:
15 * * * * /usr/bin/php /Applications/MAMP/htdocs/iconimageryidx/includes/insertPropertyRESI.php
The reason why it runs in your browser is because your server is configured to automagically compile and serve PHP files.
Cron on the other hand, doesn't have that luxury; by default it will run anything that you put into it as a bash
script.
From the looks of your Cronjob, you're running the PHP file without using the php
parser, and as such Cron tries to run the script as a bash
script.
If you put php -f
in front of the location of the PHP script, you are telling Cron to run the command using the php
parts, you should find that it will now run.
Alternatively, you could edit your code and prepend #!/usr/bin/php
to the beginning of the script. When Cron runs this file, it will use php
to run the command, instead of bash
.
Running a php file on the command line is different than running it within web server like apache. To run a php script on the command line, you need to:
- Install the package php-cli as this may not be installed by default.
- Make sure you have the comment '!#/usr/bin/php' in the first line and make sure you set 'x' permission on your php script.
- Alternatgively to 2, you just run the script by calling it using 'php your_script'