Linux USES Crontab to access a routing address periodically

  • 2020-10-23 21:18:19
  • OfStack

preface

Linux timing tasks include :cron, anacron, at, etc., and the cron service is mainly introduced here.

Noun explanation:

cron is the service name, crond is the background process, and crontab is the custom scheduled task list.

This article focuses on Linux's regular access to a routing address using Crontab, but I won't say much more. Let's start with the details

Linux periodically accesses a routing address with Crontab

You first create a timed task using linux's Crontab command, then combine that with curl to achieve regular access to a routing address. Here's how to do that.

1. First, create the timing task through crontab-e


[root@iz8vb4z6xe72mysmicu1vpz ~]# crontab -e

2. Edit the write command (using /usr/bin/curl to access a routing address), which means to access the routing address every 1 minute.


* * * * * /usr/bin/curl https://xxx.com/xxx.php

Press Esc and enter wq to save and exit

3. Restart the timer task


service crond start

4. Check the status of scheduled tasks


service crond status

5, timing command syntax parsing

[

* represents the number within the value range,
/ for every,
-is for going from a number to a number,
", separating several discrete Numbers

]

6, crontab common command


service crond start   // Start the service 
service crond stop   // Close the service 
service crond restart  // Restart the service 
service crond reload   // Reload configuration 

conclusion


Related articles: