当前位置:网站首页>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
边栏推荐
- Système de gestion - itclub (II)
- GBase 8a OLAP函数group by grouping sets的使用样例
- Common methods of string class
- Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
- MONTHS_BETWEEN函数使用
- Special tutorial - Captain selection game
- 【MySQL】数据库函数通关教程下篇(窗口函数专题)
- Summary of gbase 8A database user password security related parameters
- JVM memory structure when creating objects
- Golang uses regularity to match substring functions
猜你喜欢

PCIe knowledge point -008: structure of PCIe switch

深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图

Gao fushuai in the unit testing industry, pytest framework, hands-on teaching, will do this in the future test reports~

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

真香,自从用了Charles,Fiddler已经被我彻底卸载了

Management system itclub (Part 2)

The create database of gbase 8A takes a long time to query and is suspected to be stuck

美团20k软件测试工程师的经验分享

I think I should start writing my own blog.

vmware虚拟机PE启动
随机推荐
VMware virtual machine PE startup
Stm32cubeide1.9.0\stm32cubemx 6.5 f429igt6 plus lan8720a, configure eth+lwip
如何做好功能测试?你确定不想知道吗?
BAT测试专家对web测试和APP测试的总结
Figure countdownlatch and cyclicbarrier based on AQS queue
List of language weaknesses --cwe, a website worth learning
记一次List对象遍历及float类型判断大小
It smells good. Since I used Charles, Fiddler has been completely uninstalled by me
使用Fiddler模拟弱网测试(2G/3G)
哈希表-数组之和
GBase 8a OLAP分析函数cume_dist的使用样例
Go from introduction to practice -- shared memory concurrency mechanism (notes)
单元测试界的高富帅,Pytest框架,手把手教学,以后测试报告就这么做~
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
YOLOv6:又快又准的目标检测框架开源啦
Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app
[LeetCode]508. The most frequent subtree elements and
Golang uses regularity to match substring functions
Have time to look at ognl expressions
PCIe knowledge point -008: structure of PCIe switch