HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (
-   General (
-   -   cron job location (

Toucan 22nd June 2010 13:51

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/ 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?


Mark_NL 22nd June 2010 16:20

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

at the start of your php file.

in your crontab you would put something like:


@daily www-data /usr/bin/php /var/www/

Toucan 22nd June 2010 17:20

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


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


Mark_NL 22nd June 2010 17:50

Yeah, you can also create a small bash script to chdir to the correct dir and then call the php script :) good luck!

Toucan 22nd June 2010 22:34

I went with your suggestion changing the php. Works a treat. Thanks!

BorderAmigos 23rd June 2010 00:55

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.)

Toucan 23rd June 2010 03:36

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.

All times are GMT +2. The time now is 13:54.

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