cron job location

Discussion in 'General' started by Toucan, Jun 22, 2010.

  1. Toucan

    Toucan New Member

    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?

  2. Mark_NL

    Mark_NL New Member

    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/
  3. Toucan

    Toucan New Member

    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

  4. Mark_NL

    Mark_NL New Member

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

    Toucan New Member

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

    BorderAmigos New Member

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

    Toucan New Member

    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.

Share This Page