Cron job - Php File - Outside of root

philmcdonnell

Verified User
Joined
Jan 6, 2004
Messages
182
Location
New York
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...
 
/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
 
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
 
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
 
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
 
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.
 
Back
Top