![]() |
| | #1 (permalink) |
| Junior Member Join Date: Sep 2007
Posts: 11
| I wish to run a cron job on one of my accounts but reading through other forums there appear to be many ways to enter the URL. The most common being: either /usr/bin/php /usr/home/myusername/public_html/cron.php or wget -q -O /dev/null http://mydomain.com/cron.php What is the difference? Is either better, or makes more efficient use of resources and will both or either work on dream-hosting? |
| | |
| | #2 (permalink) |
| Administrator Join Date: Aug 2007
Posts: 1
| Hi, wget will actualy run the php script via the web server (i.e. apache). This means its exactly the same as you going to the url manually to run the php script. The preferred method (as its run from the command line so bypasses apache) is using php. The best way is: php -f /home/username/public_html/cron.php Bare in mind also that because its a cron run via the command line, it doesn't even need to be in the public_html directory, for added security you could keep it one dir above so its not accessable from the web root. To make sure your script works ok via the command line, you can log into your shell and run php -f /path/to/file.php to test it and see the output. Let me know if you have any questions. Elliot. |
| | |
| | #4 (permalink) |
| Administrator Join Date: Aug 2007
Posts: 50
| Hi, 1) The -f just means Parse and execute the file specified, technically its not needed. 2) If on the actual cron command you do: php somefile.php > operation.log 2>> errors.log That will put all the output from the script into operation.log and any script errors into errors.log, you can also get it to email you the outputs (which can be setup in cpanel) 3) It depends what the cron does, if it is quite intensive then its always best to run it when your site is at its quietest. Admin |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |