I have been wondering, is there a difference between wget [parameters], curl [parameters] and php [parameters] whilst creating a cron job?
If I have a script "cron-00-00.php" and I need to run it what would each of the mentioned above do?
0 0 * * * php -q /your_abolute_path/includes/php/cron/cron-00-00.php >/dev/null 2>&1
0 0 * * * wget -O - -q -t 1 http://your_domain_com/includes/php/cron/cron-00-00.php >/dev/null 2>&1
0 0 * * * curl http://your_domain_com/includes/php/cron/cron-00-00.php
Or is it optional to use either one(depending upon the one that best suits me)?
I currently have this thought that the 3 of them have different functions. Please correct my conceptions.
The wget command is a command line utility for downloading files from the remote servers. It's also used to triggers server side scripts using the cron jobs.
Wget is a simple transfer utility, while curl offers so much more. Curl provides the libcurl library, which can be expanded into GUI applications. Wget, on the other hand, is a simple command-line utility. Wget supports fewer protocols compared to cURL.
To schedule a curl command to run at 3am daily, you can insert the line: 0 3 * * * curl args... Notice how the minutes and hour correspond to 3am (side note: cron uses 24 hour time format, no am or pm). The asterisks that follow mean every day of month, every month, every day of week.
Running PHP directly is the simplest option. It doesn't take up a network slot on your apache (or other webserver) instance. It also bypasses limits associated with webservers that are designed to protect your machine against malicious third parties. However, the environment under which the command-line version of PHP runs is slightly different, and may be enough so to prevent a poorly-written script from behaving properly. Also, some webserver run PHP as a DSO module within apache's process space and using apache's user permissions. This might affect your results (maybe positively or maybe negatively).
Of the remaining two options, curl
seems to be slightly more widely deployed than wget
, so that would be my second choice, though they're approximately equal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With