linux 利用crontab 来设置定时任务
2016-03-17 14:39
381 查看
[size=medium]
vim /etc/crontab
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
1,crontab的格式为上.
2,下面用例子的形式来说明其作用
crontab范例
* * * * * # 分 时 天 月 星期
每五分钟执行 */5 * * * *
每小时执行 0 * * * *
每天执行 0 0 * * *
每周执行 0 0 * * 0
每月执行 0 0 1 * *
每年执行 0 0 1 1 *
2,完成好之后 启动crond服务
service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看服务状态
3,小示例
*/5 * * * * root echo `date`>>/root/log
service crond start //启动服务
启动之后,每隔5分钟就会向/root/log中写入时间
[/size]
vim /etc/crontab
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
1,crontab的格式为上.
2,下面用例子的形式来说明其作用
crontab范例
* * * * * # 分 时 天 月 星期
每五分钟执行 */5 * * * *
每小时执行 0 * * * *
每天执行 0 0 * * *
每周执行 0 0 * * 0
每月执行 0 0 1 * *
每年执行 0 0 1 1 *
2,完成好之后 启动crond服务
service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看服务状态
3,小示例
*/5 * * * * root echo `date`>>/root/log
service crond start //启动服务
启动之后,每隔5分钟就会向/root/log中写入时间
[/size]
相关文章推荐
- Linux多台服务器间SSH免密码登录配置及利用scp 两个服务器文件传输和crontab定时任务的设置
- linux利用crontab设置定时任务运行jar包
- Linux利用crontab设置定时任务
- linux定时任务的设置crontab
- linux 定时任务的设置 crontab 配置指南
- Linux下如何定时执行php脚本?Linux下如何设置定时任务?Crontab定时执行程序
- 关于ubuntu中利用crontab设置定时任务的问题
- Linux下设置任意用户的Crontab定时任务
- 利用Linux中的crontab实现分布式项目定时任务功能
- linux定时任务的设置 crontab 配置指南
- linux 中的定时任务设置 crontab
- linux下设置定时任务(crond,crontab)
- 利用CRONTAB自动定时执行任务(ARM-LINUX)
- Linux下的定时任务crontab设置
- Linux VPS主机利用Crontab实现定时重启任务
- Linux下的定时任务crontab设置
- linux定时任务的设置 crontab 配置指南
- linux应用之crontab定时任务的设置
- Linux Crontab 设置的定时任务没有启动的排查
- linux定时任务crontab的设置