例行python统计日志编写流程

来源:互联网 发布:linux 查看mysql服务 编辑:程序博客网 时间:2024/06/06 10:51

1.crontab -e 设置例行要运行的命令行:

如:33 * * * * cd /home/fangwang/statistic_scripts/routine_liuyu/;python source_iptimes_error.py -hour >>/home/fangwang/statistic_scripts/routine_liuyu/run_log 2>&1

33 * * * * 设置例行时间,此表示每小时的33分,执行一次

f1 f2 f3 f4 f5 
其中 f1 是表示分钟,f2 表示小时,f3 表示一个月份中的第几日,f4 表示月份,f5 表示一个星期中的第几天。program 表示要执行的程式。
当 f1 为 * 时表示每分钟都要执行 program,f2 为 * 时表示每小时都要执行程式,其余类推
当 f1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行,f2 为 a-b 时表示从第 a 到第 b 小时都要执行,其余类推
当 f1 为 */n 时表示每 n 分钟个时间间隔执行一次,f2 为 */n 表示每 n 小时个时间间隔执行一次,其余类推
当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行,f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行,其余类推
python source_iptimes_error.py -hour >>/home/fangwang/statistic_scripts/routine_liuyu/run_log表示python source_iptimes_error.py -hour 输出重定向到/home/fangwang/statistic_scripts/routine_liuyu/run_log 
2.python 脚本文件,分析日志文件,得到的数据入库

0 0
原创粉丝点击