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
You probably have something like a public_html directory, in which you have all the phps. Just put it outside of that directory.
public_html