linux crontab添加,linux – 如果向crontab添加每10分钟重复一次...

这个cron沙箱模拟器给你一个想法:

Mins Hrs Day Mth DoW

*/10 * * * *

This run time (UTC) Sat 2016-Jan-23 0653

Forward Schedule Sat 2016-Jan-23 0700

Sat 2016-Jan-23 0710

Sat 2016-Jan-23 0720

它使用语法:

Every nth '0-23/n', ‘*/2‘ would be every other.

‘*/1‘ is generally acceptable elsewhere, but is flagged here as possibly an unintended entry.

Let’s create a new file called “crontab” to describe our job.

* * * * * root echo "Hello world" >> /var/log/cron.log 2>&1

# An empty line is required at the end of this file for a valid cron file.

The following DockerFile describes all the steps to build your image

FROM ubuntu:latest

MAINTAINER docker@ekito.fr

# Add crontab file in the cron directory

ADD crontab /etc/cron.d/hello-cron

# Give execution rights on the cron job

RUN chmod 0644 /etc/cron.d/hello-cron

# Create the log file to be able to run tail

RUN touch /var/log/cron.log

# Run the command on container startup

CMD cron && tail -f /var/log/cron.log

Then you can build the image with

sudo docker build --rm -t ekito/cron-example .

And run it:

sudo docker run -t -i ekito/cron-example

Be patient, wait for 2 minutes and your commandline should display:

Hello world

Hello world

如果您将第一个”替换为’/ 10′,则必须等到下一个0或10或20或……小时.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值