For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > April 2007 > PHP and Crontab and Current Directory









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PHP and Crontab and Current Directory
roger.moon2@googlemail.com

2007-04-25, 6:59 pm

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

however everytime it runs via cron, it can't find the file
settings.ini because it keeps looking for it in $HOME not in $HOME/
scripts/ where test.php resides

Why? And how can I re-code it to look in the current directory not in
$HOME? I tried ./settings.ini but without success

roger.moon2@googlemail.com

2007-04-26, 7:58 am

On Apr 25, 10:26 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
> Euhm, check my reply to your previous post?
>


Sorry about that, didn't show up and thought I had crossposted to too
many groups and got halted by anti-spam scripts.

Anyway your advice worked however the problem is I have to edit the
script everytime I run the program via Cron

Instead after some googling I found this method of instead:

00 11 * * * cd /home/user1/files/; /usr/local/bin/php test.php

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com