当前位置:网站首页>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
边栏推荐
- gomock mockgen : unknown embedded interface
- Software test automation test -- interface test from entry to proficiency, learn a little every day
- Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app
- Gao fushuai in the unit testing industry, pytest framework, hands-on teaching, will do this in the future test reports~
- Test birds with an annual salary of 50w+ are using this: JMeter script development -- extension function
- [LeetCode]100. 相同的树
- 软件缺陷管理——测试人员必会
- C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。
- 石子合并问题分析
- List of language weaknesses --cwe, a website worth learning
猜你喜欢
Luogu p5706 redistributing fertilizer and house water
管理系統-ITclub(下)
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
【Redis】零基础十分钟学会Redis
∫(0→1) ln(1+x) / (x² + 1) dx
C language programming detailed version (learning note 1) I can't understand it after reading, and I can't help it.
Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移
vmware虚拟机PE启动
crontab定时任务常用命令
[leetcode] dynamic programming solution split integer i[silver fox]
随机推荐
[LeetCode]100. 相同的树
使用Jmeter进行性能测试的这套步骤,涨薪2次,升职一次
GBase 8a OLAP函数group by grouping sets的使用样例
Xiao Wang's interview training task
[LeetCode]508. The most frequent subtree elements and
gomock mockgen : unknown embedded interface
Burp suite遇到的常见问题
记一次List对象遍历及float类型判断大小
豆沙绿保护你的双眼
清华大学教授:软件测试已经走入一个误区——“非代码不可”
qt base64加解密
Selenium上传文件有多少种方式?不信你有我全!
It smells good. Since I used Charles, Fiddler has been completely uninstalled by me
How to do function test well? Are you sure you don't want to know?
管理系統-ITclub(下)
Common problems encountered by burp Suite
GBase 8a V8版本节点替换期间通过并发数控制资源使用减少对系统影响的方法
二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)
Management system itclub (Part 2)
Express e stack - small items in array