You can cron
use the tool to set up cron jobs in CentOS.
-
Open a terminal window and log in as an administrator.
-
Enter the following command to install
cron
:
yum install -y cronie
- Start
cron
the service :
systemctl start crond.service
- If you want
cron
the service to start automatically at boot, use the following command:
systemctl enable crond.service
- Check that
cron
the service :
systemctl status crond.service
- Enter the following command to edit
cron
:
crontab -e
- 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
.
- 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 curl
the command cron
to set tasks as links in . Here are the steps to set up a linked form task in CentOS:
-
Open a terminal window and log in as an administrator.
-
Enter the following command to edit
cron
:
crontab -e
- 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, curl
the command will http://example.com
send an HTTP request to .
- 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 curl
the command .