473,606 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ 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 4125
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*******@attgl obal.net
=============== ===
Jun 14 '07 #3
On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixel tomorrow.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...@attg lobal.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...@attgl obal.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...@attg lobal.netwrote:
>berksh...@gmai l.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...@attg lobal.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*******@attgl obal.net
=============== ===
Jun 15 '07 #6
On Jun 15, 2:17 pm, berksh...@gmail .com wrote:
On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixel tomorrow.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_SCRI PT_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******@pixel tomorrow.comwro te:
On Jun 15, 2:17 pm, berksh...@gmail .com wrote:
>On Jun 14, 12:51 pm, Vladimir Ghetau <vladi...@pixel tomorrow.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_SCRI PT_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
3537
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 processcollects a number of pending jobs to be run and typically creates a number of additional jobs to be run in future. The type of created jobs, their parameters and everything can be configured in the application. Fine... In addition I'd like to...
4
2040
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 permission denied result. I gave it the proper permissions and on the second try, the results say that there is no such file but it also shows some of the php code and says "syntax error near unexpected token" This script works perfectly fine when...
3
5355
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 cannot run "my" crontab. In general: Can a php-script run an external program under a different
3
5393
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 work across Linux and BSD systems. Any pointers?
2
8421
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 millions of "crontab" entries, and there will be a query run once every minute to determine which entries are to be run for that minute. The primary goal is, of course, for the query to run as fast as possible. My first stab is, straightforward...
4
3966
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. Many thanks! Chris
5
2989
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 /home/user/scripts/test.php /dev/null 2>&1
2
3870
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: * * * * * root /usr/sbin/ program_prgchk in the /usr/sbin/program_prgchk:
0
1345
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 accordingly. I had a look at the crontab docs and never realized how complex it actually is. So before I spend time in creating such a thing maybe
0
8045
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8467
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8462
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5994
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3952
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2458
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1315
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.