Reputation: 135
I have a cron job script in a php file, named cron.php
, which runs after every 3 hours. As it is kept in the public html folder, any user can access it. But I don't want that. I'm searching for a process by which I can ensure that, only my server can access that file and run that script. No user will be able to access that file.
To do that, what I need to do?
Upvotes: 0
Views: 56
Reputation: 1986
The best solution would be to store the file outside of the webroot.
Another option is to pass in an extra parameter when you run the script via cron, and check that this parameter is present (which it won't be when it's accessed by web request). See http://php.net/manual/en/function.getopt.php for examples of working with command line arguments in PHP
Upvotes: 1