博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux 任务计划:crontab
阅读量:4580 次
发布时间:2019-06-09

本文共 1567 字,大约阅读时间需要 5 分钟。

(1) 什么是任务计划:也就是设置服务器在某个指定的时间执行某个指定的任务,比如执行一个命令,或执行一个脚本

(2) Linux 使用 cron 服务来制定任务计划,cron 是服务名称,crond 是后台进程,crontab 是定制好的计划任务表
(3) cron 有两个配置文件,一个是全局配置文件(/etc/crontab),是针对系统任务的;一个是 crontab 命令生成的配置文件(/var/spool/cron/username),是针对某个用户的定时任务

# 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   --- 使用哪个用户来执行命令
[root@localhost ~]$ crontab -e              # 编辑当前用户的任务计划表[root@localhost ~]$ crontab -l              # 查看当前用户的任务计划表[root@localhost ~]$ crontab -r              # 清空当前用户的任务计划表[root@localhost ~]$ crontab -u 
-e # 编辑指定用户的任务计划表[root@localhost ~]$ crontab -u
-l # 查看指定用户的任务计划表[root@localhost ~]$ crontab -u
-r # 清空指定用户的任务计划表
[root@localhost ~]$ systemctl start crond.service    # 启动任务计划[root@localhost ~]$ systemctl stop crond.service     # 停止任务计划[root@localhost ~]$ systemctl status crond.service   # 查看启动状态
* * * * * command          # 每分钟执行一次0 3 * * * command          # 每天凌晨3点执行一次0 3 1 * * command          # 每个月1号的凌晨3点执行一次0 3 1-10 * * command       # 每个月的1-10号的凌晨3点执行一次0 3 1,10,20 * * command    # 每个月的1号/10号/20号的凌晨3点执行一次*/2 * * * command          # 每两分钟执行一次,也就是能被2整除的分钟(2,4,6,8,....)* * * */2 * command        # 每两个月执行一次,也就是能被2整除的月份(2,4,6,8,10,12)

 

 

 

 

 

    

转载于:https://www.cnblogs.com/pzk7788/p/10312487.html

你可能感兴趣的文章
python 特殊方法
查看>>
Python3 练习笔记四
查看>>
装箱问题
查看>>
Android线程管理(一)——线程通信
查看>>
vim 使用技巧
查看>>
Periodic String UVa1225
查看>>
Android 演示 DownloadManager——Android 下载 apk 包并安装
查看>>
采用oracle存储过程读取excel文件更新表
查看>>
固定虚拟机中windows系统的ip地址
查看>>
【转】正则应用实例,如将多个空格改为1个空格
查看>>
移动端自动打包平台
查看>>
gradle 使用总结
查看>>
C#函数式程序设计初探——重构应用篇
查看>>
兼容的获取选择文本方法
查看>>
谈一谈git和SVN两大版本管理工具。
查看>>
【1】Bootstrap入门引言
查看>>
PhpExcel中文帮助手册|PhpExcel使用方法
查看>>
Linux下安装rpm出现error: Failed dependencies
查看>>
Chapter 6 排序
查看>>
通用的运营商/数字在C#
查看>>