How to automatically execute the task schedule crontab every few minutes in a specified time period on Linux

How to automatically execute the task schedule crontab every few minutes in a specified time period on Linux

Look at the code first

#/bin/sh
datename=$(date +%Y%m%d-%H%M%S)
echo $datename >> /tmp/logtest.txt
*/2 19,20 * * * /bin/sh /root/1.sh

Execute every 2 minutes from 2:00 am to 7:00 pm and 8:00 pm every day

[root@dpm ~]# cat /tmp/logtest.txt
20191112-180001
20191112-180201
20191112-180401
20191112-180601
20191112-180801
20191112-181001
20191112-181201
20191112-181401
20191112-181601
20191112-181801
20191112-182001
20191112-182201
20191112-182401
20191112-182601
20191112-182801
20191112-183001
20191112-183201
20191112-183401
20191112-183601
20191112-183801
20191112-184002
20191112-184201
20191112-184401
20191112-184601
20191112-184801
20191112-185001
20191112-185201
20191112-185401
20191112-185601
20191112-185801
20191112-190001
20191112-190201
20191112-190401
20191112-190601
20191112-190801
20191112-191001
20191112-191201
20191112-191401
20191112-191601
20191112-191801
20191112-192001
20191112-192201
20191112-192401
20191112-192601
20191112-192802
20191112-193001
20191112-193201
20191112-193401
20191112-193601
20191112-193801
20191112-194001
20191112-194201
20191112-194401
20191112-194601
20191112-194801
20191112-195001
20191112-195201
20191112-195401
20191112-195601
20191112-195801

Summarize

The above is what I introduced to you about crontab, which automatically executes tasks every few minutes in a specified time period on Linux. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Django-crontab implements sample code for scheduled tasks on the server
  • Detailed explanation of the use and precautions of crontab under Linux
  • Use crontab to run the script of executing jar program regularly in centOS6
  • Laravel solves the problem of crontab not executing
  • How to notify users of crontab execution results by email
  • Analysis of the operation method of Django crontab timing task module

<<:  Detailed explanation of how a SQL statement is executed in MySQL

>>:  Detailed usage of Vue timer

Recommend

CSS3 simple cutting carousel picture implementation code

Implementation ideas First, create a parent conta...

Linux uses join -a1 to merge two files

To merge the following two files, merge them toge...

Use of provide and inject in Vue3

1. Explanation of provide and inject Provide and ...

How to install WSL2 Ubuntu20.04 on Windows 10 and set up the docker environment

Enable WSL Make sure the system is Windows 10 200...

Summary of knowledge points about events module in Node.js

Through the study and application of Node, we kno...

Example of using CASE WHEN in MySQL sorting

Preface In a previous project, the CASE WHEN sort...

Execute the shell or program inside the Docker container on the host

In order to avoid repeatedly entering the Docker ...

Node.js+postman to simulate HTTP server and client interaction

Table of contents 1. Node builds HTTP server 2. H...

JavaScript implements click to change the image shape (transform application)

JavaScript clicks to change the shape of the pict...

Vue implements the magnifying glass effect of tab switching

This article example shares the specific code of ...

How to draw a mind map in a mini program

Table of contents What is a mind map? How to draw...

Detailed tutorial on using the tomcat8-maven-plugin plugin in Maven

I searched a lot of articles online but didn'...

Vue implements carousel animation

This article example shares the specific code of ...