I would like to set up a cron job which sends an http request to a url. How would I do this? I have never set up a cronjob before.
相关问题
- Angular RxJS mergeMap types
- How to get the return code of a shell script in lu
- Google Apps Script: testing doPost() with cURL
- How to instantiate Http service in main.ts manuall
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Is a unicode user agent legal inside an HTTP heade
- Launch interactive SSH bash session from PHP
- git: retry if http request failed
Why can't you use wget. Here is another tutorial.
A cron job is just a task that get's executed in the background at regular pre-set intervals.
You can pretty much write the actual code for the job in any language - it could even be a simple php script or a bash script.
PHP Example:
Next, schedule the cron job:
... the above script will run every 10 minutes in the background.
Here's a good crontab tutorial: http://net.tutsplus.com/tutorials/other/scheduling-tasks-with-cron-jobs/
You can also use cURL to do this depending on what request method you want to use:
if you use linux
and add curl command
every day 10:15 you will send html GET request to http://test.com with param "some" and value "crontab"
Most probably you want do do this as a normal (i.e. non-privileged) user, so assuming that you are logged in as non-root user:
Add this entry to do the http request once every 5 minutes:
Preferably you don't want
script.sh
to give any output when there is no error, hence the> /dev/null
. Otherwise cron will email the output to (most likely root) every 5 minutes.That should be enough to get you started. At this point it's good if you invest some time to learn a bit about cron. You'll do well bu reading the appropriate man page for cron:
Start with the format for driving the cron jobs:
Then with the actual daemon:
General advice: make it a habit of reading the man page of any new unix tools that you encounter, instead of immediately copying and pasting command line snippets, spend some time reading what the switches do.