Hello all; it's been a bit quiet around here lately.
Once upon a time I had a cron job on a web server which used to be fine. Then it moved to a different user account on the same server and now it returns an error every time it runs. The cron job is:
0 1 * * * /usr/bin/php /home/[path]/cron.php
and the error is "Could not open input file: /home/[path]/cron.php".
(the actual path replaced by [path]).
Any ideas why this might suddenly not like me any more? The cron.php file has permissions 755. ![]()
The only thing that is popping to mind is permissions, or indeed your php.ini. Have you checked your log files to see if there are any PHP specific messages? It should tell you, if it's Safemode related for instance.
Oh, I'm not allowed to look at php.ini or log files. I'm just an end-user ![]()
Safe Mode is definitely off though. The job runs if I SSH to the command line and run the job manually (i.e. type /usr/bin/php /home/.../cron.php.
Try putting /usr/bin/php /home/[path]/cron.php into a script file and running that instead. Infact, doesn't just putting #!/usr/bin/php at the top of the file mean all you have to do it execute the file?
I'll give that a try.
This is definitely a permissions problem or the file simply does not exist at the path you specified - nothing to do with php's safemode or php.ini or anything like that. As the error says, it can't open the file.
$ sudo touch lol.php
$ sudo chmod o-rwx lol.php
$ php lol.php
Could not open input file: lol.php
$ php /file/that/does/not/exist.php
Could not open input file: /file/that/does/not/exist.php
$ sudo chmod a+rwx lol.php
$ php lol.php
$
$ [^ works]
If the file absolutely does exist where you specify and it still doesn't work you might find that crond has been chrooted or something... which may explain why it can't find your file.
For what it's worth, i run php cronjobs like so
[* crazy cron config * * *] /path/to/php -q /path/to/file.php
In fact, doesn't just putting #!/usr/bin/php at the top of the file mean all you have to do it execute the file?
Yep, it's called a shebang ![]()
I'm not allowed to sudo either... ![]()
Another option is to use lynx or wget or something if your php script is web-accessible, e.g.,
0 1 * * * /usr/bin/lynx --dump http://yoursite.com/cronscript.php
I was going to mention that ![]()
1 to 9 of 9