PDA

View Full Version : Cron job - Php File - Outside of root



philmcdonnell
07-09-2004, 11:02 AM
Hello All,

I am trying to get a cron job to run on a file every 5 mins. What is the path to use if I don't have the file inside my public_html? I don't want direct web access to these files.

Thanks,
Phil

PS. I already added the line #!/usr/local/bin/php to my files...

jmstacey
07-09-2004, 09:36 PM
/home/username/

Is the highest directory you can get to as a normal user.

*reference: your public_html folder would be in /home/username/domains/yourdomain/public_html

philmcdonnell
07-09-2004, 10:20 PM
Thanks for that info. I believe it fixed it now....

Phil

philmcdonnell
07-10-2004, 07:53 AM
Ok, the cron job is working but now my poblem is the paths to includes.

I have my cron executing a php file on level up from public_html. The file that cron executes is using an include that points to a folder inside the public_html folder.

How do I address this?

I tried to go absolute and it doesn't work, ie:

/home/user/domains/domainname/public_html/folder/

But I get a file not found or something like that.

So inside my php file what should the include look like.

Thanks,
Phil

philmcdonnell
07-10-2004, 01:47 PM
Here is the error I am getting from the actual php file that cron is executing. Remember it is one level up from public_html

/home/user/domains/domain.com/5mins.php: line 1: ?: No such file or directory
/home/user/domains/domain.com/5mins.php: line 2: syntax error near unexpected token `"./public_html/funcs.php"'
/home/user/domains/domain.com/5mins.php: line 2: `include("./public_html/funcs.php");
'

Any ideas?

Phil

thuskey
07-11-2004, 10:14 AM
replace line one which currently looks like:

<?

with:

<?php

thuskey
07-11-2004, 10:15 AM
Let me know if I can help

philmcdonnell
07-15-2004, 12:52 AM
I am still having this issue. I tried changing the ? to ?php but that didn't help. Is there something special I have to do with files that are executed outside of the public_html folder but uses includes to inside the public_html folder?

Thanks,
Phil

Hanra
07-19-2004, 04:55 AM
I had a little problem with this too, the workaround I found was simply specify the precise location of your php interpreter on the server.

e.g. * * * * * usr/bin/php yourscript.php

When I asked elsewhere it was suggested that, if you've got the right admin priviledges, you can set the location of the file cron looks at to run your php files. Since I don't have that ability I can't test that.