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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

基础 on 打工人日志

Tmux 安装和使用教程 使用 ElasticSearch Curator 7天定期删除日志 GNU/Linux 一键更换系统软件源脚本 在windows上安装appium 可观测性和监控的区别 基础知识-计算机系统 systemd 守护命令 linux常用命令 linux基础知识 yaml 语法 iptables 基础知识 网络基础知识 linux服务基础知识 mysql基础知识 shell基础知识 TCP/IP详解 运维知识图谱
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...个小时要执行,其馀类推