Is it possible to execute from crontab a php file inside a folder which is protected with htaccess and how?
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.
.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.