美文网首页
linux定时任务crontab

linux定时任务crontab

作者: 陈灬大灬海 | 来源:发表于2019-08-16 19:49 被阅读0次

    crontab -e
    选择编辑器,编辑定时任务(这里假设是编辑器是vi)

    */1 * * * * sh /chy/test.sh
    按esc退出编辑模式进入普通模式,输入:x或:wq保存退出

    重启crond:
    /sbin/service crond restart

    查看刚刚输入的定时任务
    crontab -lcat /var/spool/cron/root

    创建test.sh

    !/bin/sh

    echo "$(date '+%Y-%m-%d %H:%M:%S') hello world!" >> /chy/cron/test.log

    注意需要有对应的文件夹
    查看是否成功,可以通过 tail -fn10 /chy/cron/test.log查看是否有数据输出
    ok

    相关文章

      网友评论

          本文标题:linux定时任务crontab

          本文链接:https://www.haomeiwen.com/subject/yxxcsctx.html