CentOS 7+ 定时任务总结

来源:互联网 发布:sql授权修改表结构语句 编辑:程序博客网 时间:2024/06/04 00:26

吾生也有涯,而知也无涯.

至此,总结通过 Linux 命令(crontab)实现定时任务的功能, 如果后续有其他发现,则进一步补充完善.


crontab

  • crontab 命令常用于Unix 和类 Unix的操作系统之中,用于设置周期性被执行的指令. 百度百科.
  • Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule. The crontab files are stored where the lists of jobs and other instructions to the cron daemon are kept. Wikipedia.
  • 命令从标准输入设备读取指令,并将其存放于 etc 目录下的 “crontab”文件中,以供读取和执行。crontab文件具体内容如下图所示:
    crontab

Next. 通过实现简单的用例场景,掌握定时任务的配置等步骤信息.

  • 用例场景,定时向 demo.log 文件中输出时间信息.

  • 通过Linux终端(Terminal)编辑crontab文件.
crontab -e
  • 输入定时任务命令.
# 每分钟输出一次当前时间 * * * * * echo `date` >> /demo.log
  • 执行结果
    crontab_edit

  • 最后,希望通过此例子帮助大家快速打通在Linux环境下建立“定时任务”环节,以便尽快完成开发任务,更深入的研究则需进一步参考其他的文章。
  • 谢谢 .
原创粉丝点击