Reputation: 1461
I am trying to use a cronjob to execute a php file on a unix webserver (I use godaddy for hosting). But I am generally new to web dev., so I am unsure how to actually make sure the file is executing. The job just needs to run a php script everyday at 2:15 AM. this is what I have:
[email protected]
15 2 * * * http://mydomainname.com/refresh.php
How do I specify the file name to run, doesn't seem like I should give it a URL? Not sure where to find the file path on godaddy... Do I just load this as a .txt file?
Thanks
Upvotes: 1
Views: 106
Reputation: 1249
You can give path to file and run it using PHP command-line.
15 2 * * * home/path/to/command/your_php_script.php
15 2 * * * home/path/to/command/the_command.sh
Godaddy path is displayed Under Web hosting in the Server section, your hosting account's Absolute Hosting Path displays.
Tip: You can create a php file with echo $_SERVER['DOCUMENT_ROOT'];
then visit that page from browser this should give absolute hosting path to you.
Upvotes: 1
Reputation: 60007
You cannot use an URL in cron. It is unaware of URLs. instead create a script to run PHP with the appropriate file. You need to then supply the correct path to that script.
A useful trick to test it is to use at
first - you can then ensure that the thing will work with cron
.
Upvotes: 0
Reputation: 943586
How do I specify the file name to run
You type it where you currently have a URI.
doesn't seem like I should give it a URL?
Correct. You need a shell command.
Not sure where to find the file path on godaddy...
We don't know where you keep your files on your server. I suggest SSHing in and looking around.
Do I just load this as a .txt file?
Generally you would run crontab -e
and then use the presented editor to enter it.
Upvotes: 3