配置crontab

关键字: crontab

crontab -e编辑当前用户的crontab,这个应该没啥说的了,设置环境变量EDITOR可以更改编辑crontab的编辑器。

文件里面就是一行算是一个任务,前面5列是执行的时间,分别是 分 时 日 月 星期,在man 5 crontab里面能看到允许的值。如果是 * 则表示是所有值。然后就是这样了,如果我有一个任务需要每天的10点运行,则就写成 0 10 * * * XXX ,如果要每2小时跑一次,可以写成 0 */2 * * * XXX 。

还要说一下最后运行的那个命令,它会新开一个进程跑,那个进程只有USER, HOME, SHELL这三个环境变量,所以写命令的时候需要考虑到这一点。

下面,没有了……

This entry was posted in 小企鹅Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>