zoukankan      html  css  js  c++  java
  • Linux定时任务Crontab使用 提示no crontab for root

    使用命令查询crontab 任务时,一直提示:no crontab for root 。查看了一些资料,说是crontab在初始时,设置了一次编辑方式,所以试了一下crontab -e的方式编辑,即在命令行,输入 crontab -e ,进行编辑页面,输入定量执行的脚本

     */1 * * * * root /data/bakdb.sh  > /data/bak.log 2>&1  。crontab -e的使用方式与vi编辑器相同, 配置成功后 使用命令crontab -u root -l 可以查看当前定时任务

    具体流程:

    cd etc

    在etc目录下,执行 crontab -e  

    在插入模式下输入 0 1 * * * root /data/bakdb.sh  > /data/bak.log 2>&1

    保存

    使用命令 crontab -u root -l 可以查看当前定时任务  成功!


    crontab命令详解

    usage:    crontab [-u user] file
        crontab [ -u user ] [ -i ] { -e | -l | -r }
            (default operation is replace, per 1003.2)
        -e    (edit user's crontab)   
        -l    (list user's crontab)
        -r    (delete user's crontab)
        -i    (prompt before deleting user's crontab)


    crontab -e  

    crontab -l

    crontab实现以秒执行,很好很强大

     linux中crontab实现以秒执行任务

    很多时候,我们计划任务需要精确到秒来执行,根据以下方法,可以很容易地以秒执行任务。
    以下方法将每10秒执行一次
    1.编辑crontab
    crontab -e
    * * * * * /bin/date >>/tmp/date.txt
    * * * * * sleep 10; /bin/date >>/tmp/date.txt
    * * * * * sleep 20; /bin/date >>/tmp/date.txt
    * * * * * sleep 30; /bin/date >>/tmp/date.txt
    * * * * * sleep 40; /bin/date >>/tmp/date.txt
    * * * * * sleep 50; /bin/date >>/tmp/date.txt
    2.检查结果
    tail -f /tmp/date.txt
  • 相关阅读:
    MVC 4 异步编程简化了
    Plextor 浦科特M7VC性能
    epson Robot 指令集合
    在MFC下面实际演示CCriticalSection 的使用
    如何看MFC程序
    SCADA 必备函数之 :关于消息的函数
    SCADA必备函数 实际测试。
    (转)extern关键字两种场景的使用
    (转)全局变量、extern/static/const区别与联系
    (转 )C++ static、const和static const 以及它们的初始化
  • 原文地址:https://www.cnblogs.com/SofuBlue/p/8283597.html
Copyright © 2011-2022 走看看