Preface
Procedure (1) Check whether the crond tool is installed If it is not installed, install it using the following command: (2) Check whether the crond service is enabled . Since it is CentOS7, use the systemctl command instead of the service command. If it is not enabled, use the following command to enable the service: (3) Use the crond tool to create a task schedule crontab command usage Usage: crontab [options] file crontab [options] crontab -n [hostname] Options: -u <user> define user -e edit user's crontab -l list user's crontab -r delete user's crontab -i prompt before deleting -n <host> set host in cluster to run users' crontabs -c get host in cluster to run users' crontabs -s selinux context -x <mask> enable debugging # Note that crontab -r deletes all scheduled tasks of the user (use with caution!) You can view the task definition format and set the task execution environment through the /etc/crontab file Take "Write the date into a specified file every minute" as an example Method 1: Use the crontab command to edit the current user's scheduled task (effective immediately)** Insert the following command in the editor (note that you should not add users at this time, otherwise it will not be executed, because this method directly sets the scheduled task for the current user) Check the insertion results [tomandersen@hadoop101 bin]$ crontab -l */1 * * * * date >> /home/TomAndersen/currentDate Method 2: Edit the /etc/crontab file and insert it according to the format (slower to take effect)** */1 * * * * tomandersen date >> /home/TomAndersen/currentDate (4) Check whether the setting is successful [tomandersen@hadoop101 bin]$ cat /home/TomAndersen/currentDate Sunday, February 9, 2020 18:12:01 CST Sunday, February 9, 2020 18:13:01 CST Sunday, February 9, 2020 18:14:01 CST Sunday, February 9, 2020 18:15:01 CST Sunday, February 9, 2020 18:16:02 CST Sunday, February 9, 2020 18:17:01 CST Sunday, February 9, 2020 18:18:01 CST Sunday, February 9, 2020 18:19:01 CST Sunday, February 9, 2020 18:20:01 CST Summarize The above is the editor's introduction to using the crond tool to create scheduled tasks in Linux. I hope it will be helpful to everyone! You may also be interested in:
|
<<: Summary of three rules for React state management
>>: Method of using MySQL system database for performance load diagnosis
Table of contents Preface analyze Data Total Repe...
The main text page of TW used to have a width of 8...
Origin: A few days ago, a tester sent a requireme...
For example: <u> This has no ending characte...
There was no problem connecting to the database y...
Table of contents What is Docker deploy 1. Pull t...
introduction I used postgresql database for some ...
This is the effect to be achieved: You can see th...
1. What is CSS Animations is a proposed module fo...
Table of contents Installation Steps Environment ...
Table of contents 1. Array Induction 1. Split a s...
Table of contents Install vim plugin manager Add ...
Table of contents 1. Pull the image 2. Create a R...
This article example shares the specific code of ...
Part 3: ❤Three ways to overlook backend data rece...