LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-03-2006, 12:32 PM   #1
azwebco
LQ Newbie
 
Registered: Jun 2006
Posts: 6

Rep: Reputation: 0
cron failing do to path/permission issues


I'm not a linux guru and I'm having problems figuring out why my cron scripts won't work from the cron scheduler in cpanel even if they work when you click on them.

for instance I have a script called updates.php that needs to run every night at 1am so I schedule a cron
0 1 * * * * php updates.php

the script process but the path to the db either doesn't open or the password fails if it does open depending on the various attempts I have tried to make this work.

I use cpanel to schedule my cron and I'm running linux redhat enterprise 10 and basically I'm a php/mysql guru who tries to stay away from being a server admin. Is there some code that should be included at the top of my script to make this work?

here is one of the many errors I have gotten:
<b>Warning</b>: main(/includes/admin_nodisplay.php): failed to open stream: No such file or directory in <b>/home/xxxxxxx/public_html/upd/test_cron.php</b> on line <b>15</b><br /> <br />
<b>Warning</b>: main(): Failed opening '/includes/admin_nodisplay.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in <b>/home/xxxxxxx/public_html/upd/test_cron.php</b> on line <b>15</b><br /> hello world<br />

this is the include command that fails in cron but works from any directory at any level on the site when I use it normally:
include ("{$_SERVER['DOCUMENT_ROOT']}/includes/admin_nodisplay.php");

when I switch to absolute paths I get failed password issues when connecting to local host.
 
Old 08-04-2006, 06:25 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,089

Rep: Reputation: 207Reputation: 207Reputation: 207
Hi

When running PHP scripts as a command like you do, you don't always get the same result as running it on the web-server. I dont know anything about RedHat enterprise, but on e.g. Debian you have two different php.ini files - one for the web-server and one for CLI (command line interface). Also it's easy to mess up things like who is the running user and the environment variables.

So instead you can just make a script somewhere in the web-space, test it, and when it works, add a "wget http://localhost/..." in the cron.

If you dont want anyone to accidentally access your script, you can just check $_SERVER['REMOTE_ADDR'] and stop if not your own server.

Best regards,
Guttorm.

Last edited by Guttorm; 08-04-2006 at 07:38 AM.
 
  


Reply

Tags
cron, includes, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with cron synapse Slackware 4 07-21-2006 01:00 AM
CRON doesn't retain $PATH of user bret Suse/Novell 4 03-09-2006 01:04 PM
cron issues kaplan71 Fedora 1 10-26-2005 07:40 AM
vixie-cron issues Bigun Linux - Software 1 12-17-2004 09:08 AM
Changing the Cron Path elconde Linux - General 0 11-21-2001 05:36 PM


All times are GMT -5. The time now is 03:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration