I have php file that generates my sitemap.xml file according to DB. I have a cron job that run this php script every month. How can I protect the php file, so only cron can run it, or certified user?

(I guess I cannot add login script, and session parameters to verify the user, because I want to enable running on cron, is that correct?)


Ensure that your script has suitable group and world permissions that give only the access that is needed. Within the script you can have it check for the UID and or GID of the user running it. When allowing it to access the database give the accessing user readonly permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.