title: Linux Crontab 定时任务
date: 2018-07-01 16:01:33
categories:
- Linux
- Linux
tags: [linux,linux]
环境及版本
- Linux: Ubuntu 18.0.4
基本命令
- 格式
crontab -l 显示所有定时任务crontab -e 编辑定时任务crontab -r 删除所有定时任务
- 语法
我们用crontab -e进入当前用户的工作表编辑,是常见的vim界面。每行是一条命令
crontab的命令构成为 时间+动作,其时间有分、时、日、月、周五种 ```shell每隔一分钟执行一次
新建测试
- 新建测试脚本
#vim /root/test.sh echo 'hello' >> /root/info.log
- 赋权
chmod 777 test.sh
- /root/run.sh #每分钟执行一次 ```
- 查看效果
//实时查看日志 tail -f /root/info.log //每隔一分钟打印一遍
