zoukankan      html  css  js  c++  java
  • linux定时任务crontab

    linux定时任务crontab 主要是做一些周期性的任务,比如凌晨2点定时备份某些数据等。

    计划任务主要分为以下两种使用情况:

    1.系统级别的定时任务

    临时文件清理、系统信息采集、日志文件切割

    2.用户级别的定时任务

    定时向互联网同步时间、定时备份系统配置文件、定时备份数据库的数据。

    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) * 表示任意的(分、时、日、月、周)时间都执行
    2) - 表示一个时间范围段, 如5-7点
    3) , 表示分隔时段, 如6,0,4表示周六、日、四
    4) /1 表示每隔n单位时间, 如*/10 每10分钟

    crontab命令
    -e : 执行文字编辑器来设定时程表
    -r : 删除目前的时程表
    -l : 列出目前的时程表

    1.crontab -e 编写定时任务
    */5 * * * * /bin/sh /home/mytest/out.sh 每隔五分钟执行一次out.sh文件

    2.启动服务 service crond restart






    ==========================================================================           如果您觉得这篇文章对你有帮助,可以【关注我】或者【点赞】,希望我们一起在架构的路上,并肩齐行
    ==========================================================================
  • 相关阅读:
    resolv.conf 是什么
    Cloudera Manager Free Edition 4.1 和CDH 4.1.2 简易安装教学
    bach cello
    windows 7 旗舰版 切换 中英文 界面
    geghi 教程 以lesmiserable 为例
    python 使用 tweepy 案例: PS4
    用Live Writer写博文插入程序代码的三个插件比较
    侧滑菜单
    [Android]简略的Android消息机制源码分析
    常用git命令
  • 原文地址:https://www.cnblogs.com/amberJava/p/12366815.html
Copyright © 2011-2022 走看看