473,480 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

crontab and the include() function

We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.

Anyone know what is causing this hiccup?

TIA

Jun 14 '07 #1
7 4117
On Jun 14, 3:49 pm, berksh...@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.

Anyone know what is causing this hiccup?

TIA

Try using the server relative path in this case, or check the PHP.ini
and setup some paths in there.

So, instead of

<?php

include ('whatever.php');

?>

try
<?php

include('server/relative/path/to/the/whatever/file.php');

?>
Cheers,

Vladimir Ghetau

Jun 14 '07 #2
be*******@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.

Anyone know what is causing this hiccup?

TIA
Are you specifying absolute paths or relative paths in your include()
function?

AFAIK, this behavior hasn't changed since the early days of PHP. Did
you do something like change directories on the new version?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 14 '07 #3
On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixeltomorrow.com>
wrote:
On Jun 14, 3:49 pm, berksh...@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.
Anyone know what is causing this hiccup?
TIA

Try using the server relative path in this case, or check the PHP.ini
and setup some paths in there.

So, instead of

<?php

include ('whatever.php');

?>

try

<?php

include('server/relative/path/to/the/whatever/file.php');

?>

Cheers,

Vladimir Ghetau
Vladimir,

Thanks for th reply. Unfortunately there are quite a few includes,
and those includes have includes as well so changing hte include path
from relative paths to absolute paths isn't a practical option for us
at the momemnt.

Jun 15 '07 #4
On Jun 14, 12:57 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
berksh...@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.
Anyone know what is causing this hiccup?
TIA

Are you specifying absolute paths or relative paths in your include()
function?

AFAIK, this behavior hasn't changed since the early days of PHP. Did
you do something like change directories on the new version?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
We are specifying relative paths - which worked just fine when our old
version of php was installed. Upon upgrading these paths no longer
work. To my knowledge no other settings in php were altered, however,
there were some unused options that we left out when compiling the new
version of php although I don't think any of them are related to this
present problem.

Jun 15 '07 #5
be*******@gmail.com wrote:
On Jun 14, 12:57 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>berksh...@gmail.com wrote:
>>We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.
Anyone know what is causing this hiccup?
TIA
Are you specifying absolute paths or relative paths in your include()
function?

AFAIK, this behavior hasn't changed since the early days of PHP. Did
you do something like change directories on the new version?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

We are specifying relative paths - which worked just fine when our old
version of php was installed. Upon upgrading these paths no longer
work. To my knowledge no other settings in php were altered, however,
there were some unused options that we left out when compiling the new
version of php although I don't think any of them are related to this
present problem.
Well, obviously something changed - either in your compile or your
php.ini file. Did you have include_path set in your php.ini before?

This is a problem with either relative or absolute paths - either way
you can have problems when the path changes.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 15 '07 #6
On Jun 15, 2:17 pm, berksh...@gmail.com wrote:
On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixeltomorrow.com>
wrote:
On Jun 14, 3:49 pm, berksh...@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.
Anyone know what is causing this hiccup?
TIA
Try using the server relative path in this case, or check the PHP.ini
and setup some paths in there.
So, instead of
<?php
include ('whatever.php');
?>
try
<?php
include('server/relative/path/to/the/whatever/file.php');
?>
Cheers,
Vladimir Ghetau

Vladimir,

Thanks for th reply. Unfortunately there are quite a few includes,
and those includes have includes as well so changing hte include path
from relative paths to absolute paths isn't a practical option for us
at the momemnt.

Hey B,

How about defining a named constant, let's call it MY_SCRIPT_ROOT,
that contains the closest path to your script, let's say

<?php

define('MY_SCRIPT_ROOT', '/dev/myscript');

?>

and then, all the includes will go like this:

<?php

// an include for the /dev/myscript/includes/classes/php/
bingoclass.php
include (MY_SCRIPT_ROOT .'/includes/classes/php/bingoclass.php');
// an include for /dev/myscript/doit.php

include (MY_SCRIPT_ROOT .'/doit.php');
// an include for /dev/myscript/abc/yep.php

include (MY_SCRIPT_ROOT .'abc/yep.php');

?>
This is the best approach when you're dealing with strange paths that
go on different levels and I'm using it with success.
Vladimir

Jun 17 '07 #7
Rik
On Sun, 17 Jun 2007 15:59:37 +0200, Vladimir Ghetau
<vl******@pixeltomorrow.comwrote:
On Jun 15, 2:17 pm, berksh...@gmail.com wrote:
>On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixeltomorrow.com>
wrote:
On Jun 14, 3:49 pm, berksh...@gmail.com wrote:
We recently upgraded php from 4.3.9 to 4.4.7. Everything is working
well, except the php scripts running as cronjobs. It appears the
problem is that these scripts utilize the include() function and
these
functions are utilizing relative paths. They worked just fine with
the old version of php, but not with the new version.
Anyone know what is causing this hiccup?
TIA
Try using the server relative path in this case, or check the PHP.ini
and setup some paths in there.
So, instead of
<?php
include ('whatever.php');
?>
try
<?php
include('server/relative/path/to/the/whatever/file.php');
?>
Cheers,
Vladimir Ghetau

Vladimir,

Thanks for th reply. Unfortunately there are quite a few includes,
and those includes have includes as well so changing hte include path
from relative paths to absolute paths isn't a practical option for us
at the momemnt.


Hey B,

How about defining a named constant, let's call it MY_SCRIPT_ROOT,
that contains the closest path to your script, let's say

<?php

define('MY_SCRIPT_ROOT', '/dev/myscript');

?>

and then, all the includes will go like this:

<?php

// an include for the /dev/myscript/includes/classes/php/
bingoclass.php
include (MY_SCRIPT_ROOT .'/includes/classes/php/bingoclass.php');
// an include for /dev/myscript/doit.php

include (MY_SCRIPT_ROOT .'/doit.php');
// an include for /dev/myscript/abc/yep.php

include (MY_SCRIPT_ROOT .'abc/yep.php');

?>
This is the best approach when you're dealing with strange paths that
go on different levels and I'm using it with success.
I assume when using crons, the script doesn't get started in it's
place/dir, but in the one where the cron starts.

A simple:
chdir(dirname(__FILE__));
at the beginning of the script called by the cron should do it, every
relative include would now be indeed relative to it's directory instead of
relative to the cron.
--
Rik Wasmus
Jun 17 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3527
by: Arkascha | last post by:
Maybe someone can give me a short help with this... I got a server application in a LAMP environment doing batch tasks. A cronjob serves as a regular trigger, a metronom. The trigged...
4
2027
by: David Bruno | last post by:
I set up a crontab using cpanel8 for the first time. It's just to run a very simple php script that sends an email and has one include() function. The first try at the crontab produced a...
3
5343
by: Frank R. Suchy | last post by:
Hi, I want a php-script to maintain (some of) "my" cron jobs. Therefore it has to modify some crontab.txt (no problem) and has to execute crontab. But since php runs as the apache-user it...
3
5383
by: rbt | last post by:
How can I safely append a crontab entry to a crontab file progammatically with Python? I need to handle crontabs that currently have entries and crontabs that are empty. Also, I'd like this to...
2
8408
by: David Garamond | last post by:
I was thinking on how one would design an optimal (performance-wise) database of large number of schedules with crontab-like semantic. There will potentially be hundreds of thousands or even...
4
3952
by: Chr1s | last post by:
How do I execute a crontab command using php (not CLI) as user Joe? I don't have any problem getting output from commands such as 'ls' using passthru and exec but I am stumped with crontab. ...
5
2974
by: roger.moon2 | last post by:
So I wrote a script and at the top it checks whether a file exists like below if (!file_exists("settings.ini")) return false; and the crontab entry: 00 08 * * 4 /usr/local/bin/php...
2
3865
by: martijn | last post by:
H! I have made a program that is checking if a program is running or not. If the program is not running then it must start the program again. in the /etc/crontab: * * * * ...
0
1335
by: Martin Marcher | last post by:
Hello, is anyone aware of a crontab library. Possibly even more complete, something that will let me create/manipulate/delete crontab entries in a nice way and install the new crontab...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7059
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.