Jump to content

Cron Job in password protected directory


aeroswat

Recommended Posts

Here is what the host inserts automatically for my cron job whenever i create one

 

php -f /home/a1925824/

 

after that I type in the remaining path to the file i want to put in so that the full path would look something like this

 

php -f /home/a1925824/public_html/crons/job.php

 

and then there are several boxes i can use to set the time i want the script to execute. So I type that in and set the time to every 5 minutes of every hour of every day of every month. However my cron job does not execute. I am assuming this is because I set the crons directory to be password protected. How can I set this cron job so it works with username and password required.

I'd remove the password protection from the directory and use another way of protecting the cron scripts like by checking the clients IP. You might also be able to move your cron scripts outside of the public httpdocs.

 

Ya I tried that. I think it's because my require_once call inside of the php file is using a relative path. I'm attempting to change that right now but I'll let everyone know what happens. If anyone could help me in the mean time I'd appreciate that too :)

I'd remove the password protection from the directory and use another way of protecting the cron scripts like by checking the clients IP. You might also be able to move your cron scripts outside of the public httpdocs.

 

Ya I tried that. I think it's because my require_once call inside of the php file is using a relative path. I'm attempting to change that right now but I'll let everyone know what happens. If anyone could help me in the mean time I'd appreciate that too :)

 

If you're having problems with require_once() and relative paths, just use the full path e.g.

 

require_once('/home/a1925824/public_html/includes/myinclude.php');

Usually there is an initialisation script where the web application root is defined so that you don't need to use the full path everywhere.

 

For example

 

DEFINE('BASE_PATH', '/home/a1925824/public_html/');

 

then in any of your files which use the init script you can just include like

 

require_once(BASE_PATH . 'includes/something.php');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.