#1  
Old 22nd June 2010, 12:51
Toucan Toucan is offline
Senior Member
 
Join Date: Dec 2009
Posts: 479
Thanks: 78
Thanked 39 Times in 33 Posts
Default cron job location

I'm trying to run a script once a night that calls on some php files to update a billing status.

I've been trying to run this from the debian crontab but as the php files are stored /var/www/mydomain.com/web/billing/thephp.php cron fails to execute them are they are not stored in the same place as the where the cron job is executed from.

So my question is... in debian lenny, where does cron execute it's files from please?

David
Reply With Quote
Sponsored Links
  #2  
Old 22nd June 2010, 15:20
Mark_NL Mark_NL is offline
Senior Member
 
Join Date: Sep 2008
Location: The Netherlands
Posts: 912
Thanks: 12
Thanked 100 Times in 96 Posts
Default

You can call that php file, but if you use relative includes etc in your php file, you need to chdir first ..

you could add
Code:
chdir("/var/www/mydomain.com/web/billing/");
at the start of your php file.

in your crontab you would put something like:

Code:
@daily www-data /usr/bin/php /var/www/mydomain.com/web/billing/thephp.php
Reply With Quote
  #3  
Old 22nd June 2010, 16:20
Toucan Toucan is offline
Senior Member
 
Join Date: Dec 2009
Posts: 479
Thanks: 78
Thanked 39 Times in 33 Posts
Default

Thanks mark. I'd taken a slightly different approach and made this script which would call the php script.

#!/bin/bash
cd*./etc
/var/www/mydomain.com/web/billing/./statusupdate

when I'm back in front of a terminal I'll try your approach I think

thanks
Reply With Quote
  #4  
Old 22nd June 2010, 16:50
Mark_NL Mark_NL is offline
Senior Member
 
Join Date: Sep 2008
Location: The Netherlands
Posts: 912
Thanks: 12
Thanked 100 Times in 96 Posts
Default

Yeah, you can also create a small bash script to chdir to the correct dir and then call the php script good luck!
Reply With Quote
The Following User Says Thank You to Mark_NL For This Useful Post:
Toucan (22nd June 2010)
  #5  
Old 22nd June 2010, 21:34
Toucan Toucan is offline
Senior Member
 
Join Date: Dec 2009
Posts: 479
Thanks: 78
Thanked 39 Times in 33 Posts
Default

I went with your suggestion changing the php. Works a treat. Thanks!
Reply With Quote
  #6  
Old 22nd June 2010, 23:55
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

Another suggestion is to use full path names for all commands and files so it will run the same regardless of where it's called from. No need to change directories that way.

(Better for me as on a complicated script I can forget what directory I'm in and start messing things up.)
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
  #7  
Old 23rd June 2010, 02:36
Toucan Toucan is offline
Senior Member
 
Join Date: Dec 2009
Posts: 479
Thanks: 78
Thanked 39 Times in 33 Posts
 
Default

I see your point amigos. It was not my php script I was trying to get cron to run. It is part of an open source billing system called citrusdb.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job fails kushan Server Operation 2 9th April 2010 02:52
Cron job question autogun General 2 22nd December 2009 11:54
How to create a Cron job for ISPconfig AngelDrago HOWTO-Related Questions 1 13th January 2009 14:30
Cron job failure report torusturtle General 5 18th July 2008 14:13
cron job modified after upgrading V 2.2.5 jfruano Installation/Configuration 1 21st July 2006 12:31


All times are GMT +2. The time now is 20:52.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.