首页 > 系统服务 > 详细

linux系统定时任务设置

时间:2016-08-15 18:45:14      阅读:246      评论:0      收藏:0      [点我收藏+]

、使用at命令设置一次性定时任务

2、使用crontab设置周期性定时任务

1)cd /home 目录下,使用vi test.py创建文件,内容如下:

#!/usr/bin/python
#coding=utf-8

import time
f=open(‘f.txt‘,‘w‘)
now = time.strftime(‘%Y-%m-%d-%H_%M_%S‘,time.localtime(time.time()))
f.write(‘file run time:‘+now+‘\n‘)

f.close()

2)使用crontab -e命令编辑crontab文件

分钟 小时 天 月 星期 命令 /脚本路径(绝对路径)

5 * * * * python /home/test.py

完成crontab任务创建后,界面提示如下:

[root@host187 home]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab

3)启动 crontab 服务:
注意:在完成编辑以后,要重新启动 cron 进程,crontab 服务操作说明:
~#/etc/init.d/cron restart //重启服务
~#/etc/init.d/cron start //启动服务
~#/etc/init.d/cron stop //关闭服务
~#/etc/init.d/cron reload //重新载入配置

 

linux系统定时任务设置

原文:http://www.cnblogs.com/wensiyang0916/p/5773917.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!