shell与crontab定时器的结合

crond服务

以守护进程方式在无需人工干预的情况下来处理一些列的作业指令与服务

  • 查看服务状态

    • systemctl status cron.service

  • 停止服务

    • systemctl stop cron.service

  • 启动服务

    • systemctl start cron.service

  • 重启服务

    • systemctl restart cron.service

crontab

  • 指令格式:crontab [options]

  • -l:列出当前存在的crontab

  • -e:编辑crontab

  • -r:删除所有的任务

  • 内容格式:

    *  *  *  *  * 级别 命令(shell脚本绝对路径)
    分 时 日 月 周

    crontab时间示例

示例

每分钟向日志文件追加一行hello world

编写test.sh

编写crontab 步骤

Last updated

Was this helpful?