crontab用法

crontab可以定时执行某些操作,很实用。

通常Linux系统都已经自带。

  • 用法

    $ crontab -h
    crontab: invalid option -- 'h'
    crontab: usage error: unrecognized option
    usage:  crontab [-u user] filecrontab [ -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的命令:

    $ crontab -l
    # Edit this file to introduce tasks to be run by cron.
    #
    # Each task to run has to be defined through a single line
    # indicating with different fields when the task will be run
    # and what command to run for the task
    #
    # To define the time you can provide concrete values for
    # minute (m), hour (h), day of month (dom), month (mon),
    # and day of week (dow) or use '*' in these fields (for 'any').#
    # Notice that tasks will be started based on the cron's system
    # daemon's notion of time and timezones.
    #
    # Output of the crontab jobs (including errors) is sent through
    # email to the user the crontab file belongs to (unless redirected).
    #
    # For example, you can run a backup of all your user accounts
    # at 5 a.m every week with:
    # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
    #
    # For more information see the manual pages of crontab(5) and cron(8)
    #
    # m h  dom mon dow   command
    *   0,12   *   *   *   /bin/bash /home/adam/git2/sync.sh
    
  • 将默认编辑器从nano转为vim(可以直接添加到.bashrc or .zshrc中):

    export EDITOR="/usr/bin/vim"
    
  • 修改后看到参数,其含义分别是:

    second/minute/hour/date of month/month/date of week/command

    *表示缺省,即不考虑这个时间,

    示例表示,每天12点0分,执行命令 /bin/bash /home/adam/git2/sync.sh

Linux crontab用法相关推荐

  1. linux 如何重启crontab,Linux crontab用法、启动关闭重启操作

    感觉比https://wokan.chawen.org/post/399的内容好些 转载精哥哥最后发布于2019-06-15 12:17:56阅读数 5342收藏 crontab命令 1.在系统中有s ...

  2. crontab的用法 linux,linux crontab用法

    一.  Crontab介绍 crontab命令的功能是在一定的时间间隔调度一些命令的执行. 1.1 /etc/crontab文件 在/etc目录下有一个crontab文件,这里存放有系统运行的一些调度 ...

  3. linux下crontab命令的用法,linux 定时任务crontab用法详解

    linux 定时任务crontab用法详解 linux中crontab命令用于设置周期性被执行的指令,该命令从标准输入设备读取指令,并将其存放于"crontab"文件中,以供之后读 ...

  4. crontab的用法 linux,linux下定时执行任务的方法及crontab 用法说明(收集整理)

    linux下定时执行任务的方法 在LINUX中,周期执行的任务一般由cron这个守护进程来处理[ps -ef|grep cron].cron读取一个或多个配置文件,这些配置文件中包含了命令行及其调用时 ...

  5. linux的crontab用法与实例

    linux的crontab用法与实例 crontab的适用场景 在Linux系统的实际使用中,可能会经常让系统在某个特定时间执行某些任务的情况,比如定时采集服务器的状态信息.负载状况:定时执行某些任务 ...

  6. linux crontab 管理,linux crontab 命令详解

    linux crontab 命令详解 使用方式 : crontab [ -u user ] file crontab [ -u user ] { -l | -r | -e } 说明 : crontab ...

  7. 一文详解 Linux Crontab 调度任务

    最近接到这样一个任务: 定期(每天.每月)向"特定服务器"传输"软件服务"的运营数据,因此这里涉及到一个定时任务,计划使用Python语言添加Crontab依赖 ...

  8. crontab用法与实例

    crontab用法与实例 本文基于 ubuntu 18.04 在Linux系统的实际使用中,可能会经常碰到让系统在某个特定时间执行某些任务的情况,比如定时采集服务器的状态信息.负载状况:定时执行某些任 ...

  9. Linux crontab 命令基本说明

    Linux crontab是用来定期执行程序的命令. 当安装完成操作系统之后,默认便会启动此任务调度命令. crond 命令每分锺会定期检查是否有要执行的工作,如果有要执行的工作便会自动执行该工作. ...

最新文章

  1. mt4 不显示服务器速度,mt4显示服务器时间设置
  2. 006-spring cloud gateway-GatewayAutoConfiguration核心配置-GatewayProperties初始化加载、Route初始化加载...
  3. java 集合自定义元素_java集合 collection-list-ArrayList 将自定义对象作为元素存到ArrayList集合中,并去除重复元素。...
  4. 牛客练习赛44 A 小y的序列 (模拟,细节)
  5. 对于不是特别擅长Photoshop的人来说,熟悉和运用Photoshop工具提供的各类便捷的快捷键,是有帮助的。...
  6. php layui table,Layui table组件相关介绍
  7. for vue 一行2列_前端开发面试问什么?vue面试中经常问到的问题?用vue想拿20k,面试题要这样答!...
  8. laravel nginx配置_nginx高可用
  9. mysql8搭建innodb_cluster集群
  10. 据说:一个线程性能相当于30%核心
  11. 电脑照片抠图软件哪个好?来看看这两个简单好用的工具
  12. python接口测试第二期_上海悠悠python接口自动化测试第二期视频教程价值1600
  13. oracle报错ora-01033解决办法
  14. App工程结构搭建:几种常见Android代码架构分析
  15. javaee图书管理系统mysql,图书管理系统设计与实现—看这篇就够了
  16. 机器学习sklearn之预估器(estimator)使用
  17. 欧几里得、扩展欧几里得和中国剩余定理
  18. 长安汽车流程体系成熟度评估模型的应用
  19. 用matlab绘制抛物线y的x平方,利用matlab绘制多重x/y曲线
  20. 关于8051汇编语言的keil中出现的A45: UNDEFINED SYMBOL (PASS-2)错误

热门文章

  1. contentType与dataType
  2. 训练RBM-Hinton系列论文《A practical guide to training Restricted Boltzmann Machines》
  3. 黑猫带你学eMMC协议第7篇:eMMC各种寄存器详解(register)
  4. 安卓的商品导购app
  5. Java的窗口实例设置小图标
  6. html怎么弄br文字首行缩进,每段首行缩进2个字符如何设置CSS
  7. 简单java代码-判断闰年、平年
  8. 微信小程序——Ble之notify通信
  9. Andrej Karpathy的CVPR 2013 reading list
  10. vue3小兔鲜商城项目学习笔记+资料分享01