Linux Crontab语法和示例

Crontab is automatically scheduler used in Linux distributions. We have already looked crontab in the following tutorial. In this tutorial we will look different examples of crontab scheduler.

Crontab是Linux发行版中自动使用的调度程序。 在下面的教程中,我们已经看过crontab了。 在本教程中,我们将查看crontab调度程序的不同示例。

Linux Crontab Tutorial with Examples To Schedule Jobs

Linux Crontab教程,带有示例以计划作业

列的含义(Columns Meaning)

There are 6 columns in regular crontab file. Let’s call them like

常规crontab文件中有6列。 我们称他们为

1 2 3 4 5 backup >/dev/null 2>&1
  • 1 specifies minute

    1表示分钟

  • 2 specifies hour

    2指定小时

  • 3 specifies day of month

    3指定一个月中的某天

  • 4 specifies month of year

    4指定一年中的月份

  • 5 specifies weekday

    5指定工作日

  • backup >/dev/null 2>&1 specifies the command we want to run

    backup >/dev/null 2>&1指定我们要运行的命令

*或每个(* or Every)

* is used to specify for every for correspondent column. For example if we use * in hour column this means every hour.

*用于为每个对应列指定。 例如,如果我们在小时列中使用* ,则表示每小时。

每分钟运行命令 (Run Command In Every Minute)

We can run a command at every minute like below.

我们可以像下面这样每分钟运行一次命令。

* * * * * backup

每小时运行一次命令 (Run Command Every Hour)

We will set the minute to  which is start of every hour

我们将分钟设置为这是每个小时的开始

0 * * * * backup

每6小时执行一次命令 (Run Command Every 6 Hours)

We will divide * which means every time 6 hours from 00:00

我们将*分开,这意味着从00:00开始每6个小时

0 */6 * * * backup

每天10:00运行命令 (Run Command Every Day At 10:00)

We explicitly specify the hour we want to run which is 10

我们明确指定要运行的小时数为10

0 10 * * * backup

每周周日03:00运行命令 (Run Command Every Week Sunday 03:00)

We can also run backup command every week Sunday at 03:00 o’clock.

我们还可以在每周的周日03:00运行backup命令。

0 3 * * Sun backup

每年1月1日10:00 (Run Command Every Year 1’st January 00:00)

0 0 1 1 * backup
LEARN MORE  Schedule Jobs and Tasks With Windows At Command
了解更多信息使用Windows At Command计划作业和任务

翻译自: https://www.poftut.com/linux-crontab-syntax-examples/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值