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
1. System Configuration 1. Turn off sudo password...
We all know that the underlying data structure of...
This article example shares the specific code of ...
Just 15 lines of CSS to crash your iPhone Securit...
In the previous article, I introduced the functio...
How to delete the container created in Docker 1. ...
1: Install SVN yum install -y subversion 2. Creat...
Table of contents 1. concat() 2. join() 3. push()...
CSS3 syntax: (1rem = 100px for a 750px design) @m...
Table of contents Preface text 1. Closure 1.1 Wha...
1. Installation process MySQL version: 5.7.18 1. ...
yum or rpm? The yum installation method is very c...
Table of contents 1. Component Introduction 2. So...
Method 1: Install the plugin via npm 1. Install n...
Table of contents Write docker-compose.yml Run do...