centos set timing task

You can cronuse the tool to set up cron jobs in CentOS.

  1. Open a terminal window and log in as an administrator.

  2. Enter the following command to install cron:

yum install -y cronie
  1. Start cronthe service :
systemctl start crond.service
  1. If you want cronthe service to start automatically at boot, use the following command:
systemctl enable crond.service
  1. Check that cronthe service :
systemctl status crond.service
  1. Enter the following command to edit cron:
crontab -e
  1. Add a task line in the editor. For example, if you want to run the script every day at 2 o'clock, you should add the following line:
0 2 * * * /path/to/script.sh

This command means to run the script at 2 o'clock every day /path/to/script.sh.

  1. After adding the task, save and close the editor.

You have now successfully set up a cron job. If you need to perform more tasks, add more lines, and set the time and command as desired.

You can use curlthe command cronto set tasks as links in . Here are the steps to set up a linked form task in CentOS:

  1. Open a terminal window and log in as an administrator.

  2. Enter the following command to edit cron:

crontab -e
  1. Add a task line in the editor. For example, if you want to send an HTTP request to a certain URL every day at 2 o'clock, you should add the following line:
0 2 * * * curl http://example.com

This command indicates that at 2 o'clock every day, curlthe command will http://example.comsend an HTTP request to .

  1. After adding the task, save and close the editor.

You have now successfully set up a linked task. Note that if your task requires authentication or requires additional curl options, add additional options and parameters after curlthe command .

Guess you like

Origin blog.csdn.net/qq_27487739/article/details/131042651