crontab simple usage
crontab generally comes with the linux system.
Enter the following command to add a scheduled task. There are instructions and examples of crontab in it.
crontab -e
The sample format is as follows
# 前面五个分别代表分、时、天、月、周,后面就是命令
* * * * * command
For example,
* * * * * command
if it is executed every minute,
5 * * * * command
it is executed at the fifth minute of each hour,
30 6 * * * command
that is, the command is executed at 6:30 every morning,
and so on.
curl simple usage
Curl is also generally included in the linux system and can be used to send requests
Example requests
curl http://www.baidu.com
By default, a GET request is sent without parameters.
Common parameters
-X 指定请求方式,例如 -X POST
-d 添加请求体的请求参数,增加此参数请求默认变为POST请求,例如 -d "username=sywdebug&password=888888"
-k 跳过ssl验证,如果不加此参数请求https的话会报错
-H 添加请求头,例如 -H {token:sbfjabdoobfda}
-i 获取响应体和响应头
-v 获取响应过程
-I 仅获取响应头
Topic
Create a new test.sh executable file
Request the command to be added
Save and then give execution permission to test.sh
Use the following command to open the crontab timing task file for editing
crontab -e
Set the execution time and command, execute the test.sh file every minute, and output the response to the test.log file
After a while, check the files in the folder, and you can see that there is already an additional test.log
You can see that the requested results have been output.