Question

Is it possible to execute from crontab a php file inside a folder which is protected with htaccess and how?

Was it helpful?

Solution

.htaccess is a way to limit access from outside (the Internet) and is enforced by the apache. So there's nothing preventing the crontab to run the script.

OTHER TIPS

I believe crontab can execute any of your scripts. .htaccess just plays over your web access so it should not stop crontab from executing it.

No. If htaccess is set to deny access from the web it will prevent any web based method from accessing it. Running wget or curl from the commandline is just the same as accessing it in a browser and htaccess will stop it.

You can restrict access to the page with an authentication scheme and make the cron script authenticate and then it will work, but if htaccess is denying access, you can't access it.

It is possible to run php from the commandline without accessing from the web but it's iffy, here's a link that describes how to do it.

i've a .htaccess protected area and use a cronjob created via Plesk.

you have to call your url with the php script. Try this:

http://username:password@www.yourDomain.com/protected_area/YourScript.php

username and password are your desired data for .htaccess

hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top