I have this script.php file which i want to run as a cron job on my linux/apache server.
However, i do not want public to access www.mycompanyname.com/script.php and
If you put the script outside of the webroot folder it will not be accessible through your webserver. e.g. your webroot is at /var/www/public_html/ you put the script.php outside of that folder, for example: /var/www/