当前位置:网站首页>Crontab scheduled task common commands
Crontab scheduled task common commands
2022-06-27 22:05:00 【Technical column of qingpingle】
One 、 Common commands

1、 see crontab Task list
crontab -l
2、 edit crontab Scheduled tasks
crontab -e
3、 Delete crontab Timing task
crontab -r
4、 Relevant command :
systemctl start crond.service # Start the service
systemctl stop crond.service # Close the service
systemctl status crond.service # View service status
systemctl restart crond.service # Restart the service
Two 、 Timed syntax
crontab A time expression :
The basic format :
* * * * * command
branch when Japan month Zhou command
Let's start with an example . Every morning 1:00 Execute the backup program :0 1 * * * /root/backup.sh . among /root/backup.sh This is the script path , To use absolute paths , For the previous date format, please look directly at the figure below 
crontab And operators , It needs to be used to realize some complex time setting . Operators have :
1、* All numbers in the range , On behalf of all .
2、/ How many numbers are passed , Represents every n Long-term .
3、- from X To Z , For a period of time .
4、, Hash numbers , Represents splitting multiple values .
If you still don't understand the code formula , You can use this online Cron Expression generator :http://cron.qqe2.com/
3、 ... and 、20 Classic examples
Remember to replace it with your own script path . Please add... To the first line of the corresponding script #!/bin/bash, Otherwise, the script cannot be executed in the scheduled task .
example 1: Every time 1 Once per minute
* * * * * /root/backup.sh
example 2: At the end of every hour 3 Minutes and the 15 Once per minute
3,15 * * * * /root/backup.sh
example 3: Daily 8 Point to 11 Point of the first 3 And the 15 Once per minute
3,15 8-11 * * * /root/backup.sh
example 4: Every other morning 8 Point to 11 Point of the first 3 And the 15 Once per minute
3,15 8-11 */2 * * /root/backup.sh
example 5: One morning a week 8 Point to 11 Point of the first 3 And the 15 Once per minute
3,15 8-11 * * 1 /root/backup.sh
example 6: Every night 21:30 Do it once
30 21 * * * /root/backup.sh
example 7: monthly 1、10、22 Japanese 4 : 45 Do it once
45 4 1,10,22 * * /root/backup.sh
example 8: Every Saturday 、 Sunday's 1 : 10 Do it once
10 1 * * 6,0 /root/backup.sh
example 9: Every day 18 : 00 to 23 : 00 Between every 30 Once per minute
0,30 18-23 * * * /root/backup.sh
example 10: Every Saturday night 23: 00 pm Do it once
0 23 * * 6 /root/backup.sh
example 11: Every hour
* */1 * * * /root/backup.sh
example 12: Every night 23 From o'clock to the next morning 7 Between points , It is performed every hour
* 23-7/1 * * * /root/backup.sh
example 13: On the first day of each week ( That is, every Sunday night 24:00 Start execution ).
@weekly /root/backup.sh
example 14: Monthly 15 Once a day .
0 11 15 * * /root/backup.sh
example 15: On the first day of each month ( I.e. monthly 1 Early morning 0 Start at ).
@monthly /root/backup.sh
example 16: Execute once in the specified month ( stay 1 month ,4 The month and 6 Every night in June 0 Click to execute once ).
0 0 * jan,apr,jun * /root/backup.sh
example 17: Execute once after restart .
@reboot /root/backup.sh
example 18: Send an email notification after the scheduled task is executed .
MAILTO="raj"
1 1 * * * /root/backup.sh
example 19: Appoint shell ( The default is /bin/bash)
SHELL=/bin/sh
1 1 * * * /root/backup.sh
example 20: Specify environment variables .
PATH=/sbin:/bin:/usr/sbin:/usr/bin
1 1 * * * /root/backup.sh
边栏推荐
- crontab定时任务常用命令
- 清华大学教授:软件测试已经走入一个误区——“非代码不可”
- 读写分离-Mysql的主从复制
- Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app
- win11桌面出現“了解此圖片”如何删除
- How to design an elegant caching function
- 【Redis】零基础十分钟学会Redis
- Matlab finds the position of a row or column in the matrix
- Go from introduction to actual combat - only any task is required to complete (notes)
- [LeetCode]186. Flip word II in string
猜你喜欢

Stm32cubeide1.9.0\stm32cubemx 6.5 f429igt6 plus lan8720a, configure eth+lwip

Luogu p5706 redistributing fertilizer and house water

Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移

List of language weaknesses --cwe, a website worth learning

使用Fiddler模拟弱网测试(2G/3G)

Set code exercise

6G显卡显存不足出现CUDA Error:out of memory解决办法

Bit. Store: long bear market, stable stacking products may become the main theme

Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear

. Net learning notes (V) -- lambda, LINQ, anonymous class (VaR), extension method
随机推荐
使用Fiddler模拟弱网测试(2G/3G)
IO stream code
Gbase 8A OLAP analysis function cume_ Example of dist
xpath
Process control task
01 golang environment construction
I think I should start writing my own blog.
石子合并问题分析
Go 访问GBase 8a 数据库的一个方法
单元测试界的高富帅,Pytest框架,手把手教学,以后测试报告就这么做~
軟件測試自動化測試之——接口測試從入門到精通,每天學習一點點
AQS SOS AQS with me
Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移
洛谷P5706 再分肥宅水
Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
The create database of gbase 8A takes a long time to query and is suspected to be stuck
Common problems encountered by burp Suite
[LeetCode]161. 相隔为 1 的编辑距离
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
GBase 8a OLAP分析函数cume_dist的使用样例