Hide Cronjob error (Undefined SCRIPT Name)
Hi guys,
after I set up my path to the cronjob and switched in the Adminpanel to cron I get following error message:
Notice: Undefined index: SCRIPT_FILENAME in /home/www/web/html/cloud/lib/base.php on line 137
Notice: Undefined index: SCRIPT_NAME in /home/www/web/html/cloud/lib/request.php on line 93
After a discussion in the owncloud forum
http://forum.owncloud.org/viewtopic.php?f=23&t=11301
there might be the possibility to switch off or filter for script names they are not set in the php client!?!
Thanks for any help or suggestions in advance.
I’m closing this issue because it has been inactive for a few months. This probably means that the issue is not reproducible or it has been fixed in a newer version.
Please reopen if you still encounter this issue with the latest stable version (currently ownCloud 5.0.9) and then please use the issue template. You an also contribute directly by providing a patch – see the developer manual. :)
Thank you!
Hi,
unfortunately I get the same error as mentioned above. As soon I switch on my crontab the error log of the cron contains for every time it runs following entry:
Notice: Undefined index: SCRIPT_FILENAME in /home/www/web/html/owncloud/lib/base.php on line 137
Notice: Undefined index: SCRIPT_NAME in /home/www/web/html/owncloud/lib/request.php on line 100
It would be nice if "Undefined script names" could be hidden or it could be on another way be fixed. Otherwise I get for every error an Email or my cron log is running full and I have to delete this log daily.
Web server: Apache (Linux) with Confixx
Database: MySQL
PHP version: 5.3
ownCloud version: 5.0.9
EDIT:
How to re-open the issue???
Ok, reopening. @DeepDiver1975 @bantu @ringmaster @VicDeo can you have a look?
My thought is that if you are seeing errors related to SCRIPT_NAME and SCRIPT_FILENAME, it's because calling cron.php from CLI doesn't define those elements in the $_SERVER array when you're not running the script via CGI/SAPI. Without looking in more detail (I've only just read through your report and looked at the code causing the error), I don't know what in cron.php might cause that code to be called since there are specific checks to rule that out. It could be a poorly-behaving plugin, it could also be that ownCloud is not detecting your CLI usage correctly.
The fastest way to potentially address the issue is to call cron.php via curl or wget in the crontab instead of executing it directly. Doing so should cause those values to be present in the array, which should address the error.
On my system, I see no errors when running the cron.php directly with the forum script. It would be useful to see the output of php_sapi_name() on your system. Put this into a file called test.php on your server:
<?php echo php_sapi_name(); ?>
Then in the shell, call /usr/bin/php test.php and post the results.
Hi,
Thanks for looking into it. I have to be honest and need to say that I am quite inexperienced with the topic cronjob. My owncloud is running on a hosted webspace and I don't have any other access then via ftp or confixx to adjust things. Also the cronjob I just activate over the standard confixx surface with that command.
*/1 * * * * /usr/local/php5.3/bin/php -f ~web/html/owncloud/cron.php
I am using the standard plugins the only change to it was activating the task plugin and I installed the mozilla_sync plugin. I remember that I removed the mozilla_sync plugin and checked it without, but I got the same error.
I was not quite sure how to run the test.php, so I did it directly over the browser and I did it via cronjob with
*/1 * * * * /usr/local/php5.3/bin/php -f ~web/html/test.php
in both cases it returned just: cgi-fcgi
I had to read a bit about wget and tried to figure out how it works. Apparently I had issues that I couldn't solve.
I had to switch off my ssl encryption I gave my owncloud folder and cron.php more access (777)
I used following command:
*/1 * * * * wget http://my.domain.com/cron.php
But I got just back that the cron.php has no write access.
--2013-08-09 07:35:01-- http://my.domain.com/cron.php Resolving my.domain.com... 11.22.333.44 Connecting to my.domain.com|11.22.333.44|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/json] cron.php: Permission denied
Cannot write to `cron.php' (Permission denied).
Don't know what I can do differently to get it work?
That's a lot of great info. The salient bit is the result of running test.php, 'cgi-fcgi', which is just plain weird. When PHP runs from the command line, like your cron configuration suggests it does, the result should be "cli", which is what ownCloud looks for. This may explain why you're seeing errors.
You could try the wget method again. Something like this should work:
*/1 * * * * wget -q -O /dev/null "http://my.domain.com/cron.php"
The extra options prevent wget from trying to write the results of the request to disk. I suspect this is the error you saw, not that the cron.php script itself needs to be writable.
If you use this wget method, you'll also want to switch the cron setting in ownCloud to the Webcron option.
Thanks a million for your help.
I used now the wget command above and I do not get any error messages. I am wondering now how I can see whether it works or not???
With my early try to get wget to work I got ssl certificate errors. The reason is that it is just an server certificate and I don't have an own one. Now is there nothing, no hint if there is any trouble wit the certificate???
@MeCias Are you actually using HTTPS, i.e. does your URL begin with https://?
Ỳou can use the --no-check-certificate option of wget in order to ignore the non-trusted certificate warning.
Yes, any SSL errors will likely be suppressed by the -O /dev/null. You could try adding the --no-check-certificate flag to the wget call, ala wget -q --no-check-certificate -O /dev/null "http://my.domain.com/cron.php"
If your ownCloud is set up like mine, it's automatically redirecting to the SSL version, even if you request the non-SSL version.
@ringmaster -O specifies where the content is downloaded to. It does not redirect stdout or stderr of wget, the certificate error message should be visible.
Yeah, I am using https in the wget link and my domain is forced forwarded to https and additional I am using in owncloud the https setting. So it is setted up on three ways.
Still don't know if it runs now probably, because I don't see anything. No error and no success message.
If it would not run as expected, do I see then after a while that owncloud runs more slow then usually or do I see any other side effects???
@MeCias If i get it right errors should still be logged with the solution above. is it still an issue?
Hi,
With wget and suppressing the SSL errors it is working fine. Since then it was never an issue again.
Thanks.
thanks for the feedback, closing
Check this post for possible solution: https://forum.owncloud.org/viewtopic.php?f=36&t=31420