惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

运维 on 打工人日志

Tmux 安装和使用教程 使用 ElasticSearch Curator 7天定期删除日志 GNU/Linux 一键更换系统软件源脚本 在windows上安装appium 可观测性和监控的区别 systemd 守护命令 linux常用命令 linux基础知识 yaml 语法 iptables 基础知识 网络基础知识 linux服务基础知识 mysql基础知识 shell基础知识 运维知识图谱
Linux crontab 命令
2022-02-22 · via 运维 on 打工人日志

Linux crontab 命令

Linux crontab是用来定期执行程序的命令。

  1. 系统执行的工作:系统周期性所要执行的工作,如备份系统数据清理缓存
  2. 个人执行的工作:某个用户定期要做的工作,例如每隔10分钟检查邮件服务器是否有新信,这些工作可由每个用户自行设置

语法

1crontab [ -u user ] file
2crontab [ -u user ] { -l | -r | -e }

说明:
crontab 是用来让使用者在固定时间或固定间隔执行程序之用,换句话说,也就是类似使用者的时程表。

-u user 是指设定指定 user 的时程表,这个前提是你必须要有其权限(比如说是 root)才能够指定他人的时程表。如果不使用 -u user 的话,就是表示设定自己的时程表

参数说明:

-e : 执行文字编辑器来设定时程表,内定的文字编辑器是 VI,如果你想用别的文字编辑器,则请先设定 VISUAL 环境变数来指定使用那个文字编辑器(比如说 setenv VISUAL joe)
-r : 删除目前的时程表
-l : 列出目前的时程表

时间格式如下:

1f1  f2   f3   f4   f5    program
2*    *    *    *    *
3-    -    -    -    -
4|    |    |    |    |
5|    |    |    |    +----- 星期中星期几 (0 - 6) (星期天 为0)
6|    |    |    +---------- 月份 (1 - 12)
7|    |    +--------------- 一个月中的第几天 (1 - 31)
8|    +-------------------- 小时 (0 - 23)
9+------------------------- 分钟 (0 - 59)

其中 f1 是表示分钟f2 表示小时f3 表示一个月份中的第几日f4 表示月份f5 表示一个星期中的第几天program 表示要执行的程序。 当 f1 * 时表示每分钟都要执行 program,f2* 时表示每小时都要执行程序,其馀类推 当 f1a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行f2a-b 时表示从第 a 到第 b 小时都要执行,其馀类推 当 f1*/n 时表示每 n 分钟个时间间隔执行一次f2*/n 表示每 n 小时个时间间隔执行一次,其馀类推 当 f1a, b, c,... 时表示第 a, b, c,... 分钟要执行f2a, b, c,... 时表示第 a, b, c...个小时要执行,其馀类推