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

Detailed process of building nfs server using Docker's NFS-Ganesha image

Table of contents 1. Introduction to NFS-Ganesha ...

Detailed explanation of json file writing format

Table of contents What is JSON Why this technolog...

js implements random roll call

This article shares the specific code of js to im...

SQL implementation of LeetCode (181. Employees earn more than managers)

[LeetCode] 181.Employees Earning More Than Their ...

Example of implementing load balancing with Nginx+SpringBoot

Introduction to Load Balancing Before introducing...

Native JS to implement login box email prompt

This article shares a native JS implementation of...

Docker installation and configuration command code examples

Docker installation Install dependency packages s...

uniapp implements date and time picker

This article example shares the specific code of ...

Three common methods for HTML pages to automatically jump after 3 seconds

In practice, we often encounter a problem: how to...

How to implement call, apply and bind in native js

1. Implement call step: Set the function as a pro...

Use Xshell to connect to the Linux virtual machine on VMware (graphic steps)

Preface: I recently started to study the construc...

How to use docker to build redis master-slave

1. Build a Docker environment 1. Create a Dockerf...

Specific use of pthread_create in linux to create threads

pthread_create function Function Introduction pth...