PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Sep 19, 2019 12:36 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu Sep 10, 2009 7:23 pm 
Offline
Forum Newbie

Joined: Thu May 14, 2009 9:59 am
Posts: 5
Okay, first off let me say I'm a relative newbie, so please be kind.

I've created a crontab task in my Plesk Control Panel. Here is the command:
/usr/bin/php -q /var/www/vhosts/mysite.com/httpdocs/crontask.php

This task works fine as long as the file it is calling (in this case crontask.php) doesn't use includes or anything that calls another outside file. That's when it simply doesn't work.

Now I realize this is an environment issue and running the script through crontab task is NOT like running the script through a browser. What I can't figure out is how to either 1) amend the crontab command to run the script as though it was being executed from a browser where relative paths work, or 2) amend the php file so any includes or whatever can be properly called on.

I've tried placing this at the top of the php file (above <?php): #!/usr/bin/php
But that doesn't work.

I've tried using absolute paths in the php file such as:
include("/var/www/vhosts/mysite.com/httpdocs/crontask_include1.php");
But that doesn't work.

I've tried just about everything I can think of and have spent hours looking for solutions online but to no avail.

Does anyone here have an idea how to help a newbie like me with what I realize is probably a simple solution? I would be very grateful.

Thanks!


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 3:06 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 2:26 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 7:11 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Sat Sep 12, 2009 11:11 am 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria


Top
 Profile  
 
PostPosted: Sun Sep 13, 2009 4:21 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Sun Sep 13, 2009 6:15 am 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
OK, maybe it depends on some circumstances, I had headaches with such scripts on live servers.
And another reason you have to use some kind of absolute path is that your script may be included, and I'm sure in that case the include in your script will be relative to the path of the script that included yours.


Top
 Profile  
 
PostPosted: Sun Sep 13, 2009 9:58 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group