crontab 是在linux服务器上部署定时任务的方法0 5 * * * /usr/bin/python /data/www/tools/mysql_backup.pycmd之前有5个项目要填,分别对应分钟 小时 天 月 一周当中第几天( 0-6 ,0表示星期天)填写方法* 表示都满足,例如 * * * * * 表示每分钟执行一次,如果每小时执行一次,那应该这样写
1 * * * * (每小时第一分钟执行,1可以随便改成60以内的数字)
/n 表示隔n个单位执行一次
/3 * * * * 3分钟执行一次
1 */3 * * * 表示每隔3个小时的第一分钟执行一次
1 1 */3 * * 表示每隔3天,当天的1点1分执行一次
1 12 * * 2,3,4,5,6 表示每周二到周6,每天中午12点1分执行
只需要掌握这2种时间用法,crontab就ok了提示:crontab 最小粒度是一分钟执行一次,要更快,得用其它办法,比如说写一个daemon程序,用while true: 来做
crontab -l 查看所有crontab 列表
cronta -e 编辑crontab
crontab条目是以文件方式存储的,可以用ls /etc/cron* 查看
标签: linuxcrontab本文地址: http://lutaf.com/51.htm 鲁塔弗原创文章,欢迎转载,请附带原文链接

  

Create a script you wish to run. For this example, I am going to use the awstats.pl script to update my stats. The command to run the update is: /path/to/awstats.pl -update -config=myconfig2. Create a new crontab file for your user. This is accomplished by opening the Terminal.app, found in your Application/Utilities folder. Type the following into the terminal:crontab -eIf you do not have a crontab file, one will be created for you and opened in vi.3. Choose when you would like the job to run. Every job is a line in your crontab file. The first 5 arguments specify the time to run the job, and the 6th argument is the command to run. Argument 1: Minute (0 - 59)
Argument 2: Hour (0 - 23)
Argument 3: Day of Month (1 - 31)
Argument 4: Month (1-12)
Argument 5: Day of Week (0 - 6) Sunday = 0
Argument 6: CommandSo if I want to update my stats every 30 minutes, my entry in my crontab file will look like this:*/30 * * * * /path/to/awstats.pl -update -config=myconfigSave the file, and crontab should report: crontab: installing new crontabTo see a list of your crontabs, run this command: crontab -lThat's it! Crontab will now update the stats every half hour. It also will generate an email to your local user account to let you know it did its job. Most times your local user account's mailbox will not be where you want to be notified. To forward your email, create a file in your home directory called .forward. In the file put the email address where you would like the notification to be sent to.

有的人抱怨说 crontab 无论正确输出还是错误输出都会往 /var/mail/*** 目录下发送邮件 append方式, 不知道别人怎么样,在mac环境下不会出现这种情况,除非 ****** cmd , cmd 有运行错误,就会输入到/var/mail/*** 里面。

转载于:https://www.cnblogs.com/IamThat/p/4360794.html

mac 下周期调度命令或脚本相关推荐

  1. Mac下使用可执行脚本记录远程服务器账号和密码

    安装工具 brew install expect brew install spawn-fcgi 编写可执行脚本 例如~/.wiwide_dev.sh #!/usr/bin/expect set us ...

  2. mac下如何运行sh脚本文件

    一.编辑一个 .sh 脚本文件 假设我的脚本文件名为 nice.sh 以下讲解如何运行 nice.sh 二.给shell脚本赋权限 有三种方法 # 方法一 chmod a+x nice.sh# 方法二 ...

  3. mac下直接运行python脚本

    新建a.py 文本文件, 写内容如下 : #!/usr/bin/env python #coding:utf-8print "hello" 注意, py文件的回车换行需要是unix ...

  4. mac下安装mongodb

    先去官网下载http://www.mongodb.org/downloads 建议下载64位的,32位的有一些限制,这个看书都会提到 我下载的是mongodb-osx-x86_64-2.0.3.tgz ...

  5. Mac下png转icns图标脚本

    原文地址:https://kevinlu98.cn/archives/51.html 写了一个mac下png转icns的脚本,我是将其放入环境变量中方便使用 效果如下 脚本内容 #!/bin/bash ...

  6. mac下脚本自动安装brew

    mac下安装brew 执行命令: /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homeb ...

  7. 在mac下搭建java开发环境

    刚刚从windows系统转到使用mac系统,感觉不是特别熟悉,需要一定的适应时间.下面简单介绍一下mac下搭建基本的java开发环境. 1.安装jdk 安装jdk1.7后,发现不需要进行环境变量配置, ...

  8. Mac下编译ffmpeg出现“ERROR: x265 not found using pkg-config”

    x265已经编译成功,但是ffmpeg/configure出现错误 ERROR: x265 not found using pkg-config 看了一下config.log,出了一坨"Un ...

  9. Mac下python初学之Image库(PIL)

    Mac下python 使用Image库 安装PIL,下载http://www.pythonware.com/products/pil/ 解压PIL源码包,阅读README知道需要使用python se ...

最新文章

  1. 超大数据下大批量随机键值的查询优化方案
  2. python中文对齐_Python中英文对齐终极解决方案
  3. 高阶奇异值分解(HOSVD)理解
  4. linux centos 编译Lua5.2.0 静态库 动态库
  5. squid 服务器的应用
  6. SqlServer数据冗余的问题和解决
  7. 安装caffe-yolov3时报错:ImportError: No module named torch(环境变量设置)
  8. Some normal compiling and debugging commands for C# 常见C#调试和编译命令
  9. 批处理(bat)没有后缀的文件怎么复制?
  10. 防护ddos无从下手?了解ddos原理轻松应对危机
  11. WRF运行wrf.exe出现forrtl: severe (174): SIGSEGV, segmentation fault occurred问题原因与解决合集
  12. 微信小程序标题栏放logo 搜索框
  13. 蒙特卡罗算法的matlab实现
  14. Activiti设置流程发起人用户信息
  15. C#练习题答案: 产品和LCMS之间的差异总和【难度:1级】--景越C#经典编程题库,1000道C#基础练习题等你来挑战
  16. 【python期末设计(节选)】志愿者管理系统开发包含源码软件工程
  17. 德国的Duisburger Modellfabrik公司把WorkNC用于精密工程和大型模具制造
  18. 2022-2028年全球与中国汽车铝压铸件行业深度分析
  19. iOS开发之fastlane自动化打包工具安装和使用
  20. 王城英雄无限钻石服务器,王城英雄手游最新版-三七王城英雄官方正版-艾艾手游...

热门文章

  1. linux 6.7 nfs安装yum,centos7下NFS使用与配置
  2. 敲代码括号技巧_阅码神奇Souceinsight使用小技巧总结
  3. 搜狗输入法电脑版_搜狗输入法小米版升级简介
  4. docker安装linux桌面系统,Hostwinds云主机 – Docker安装Xfce桌面环境(轻量可视化操作系统)...
  5. python 面向对象(云储存一下)
  6. mysql数据库查询全部信息_mysql 查询怎么获取数据库下所有表的信息?
  7. 计算机的参数配置选项在哪,教你电脑win7如何进去bios设置相关参数
  8. 齐次坐标的理解(1)
  9. STM32电源框图解析(VDD、VSS、VDDA、VSSA、VREF+、VREF-、VBAT等的区别)
  10. 读后感与机翻《基于理论的因果迁移:结合实例级的归纳和抽象级的结构学习》