mac 下周期调度命令或脚本
crontab 是在linux服务器上部署定时任务的方法 0 5 * * * /usr/bin/python /data/www/tools/mysql_backup.py cmd之前有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=myconfig 2. 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 -e If 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: Command So 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=myconfig Save the file, and crontab should report: crontab: installing new crontab To see a list of your crontabs, run this command: crontab -l That'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/*** 里面。
mac 下周期调度命令或脚本的更多相关文章
- Mac下Shell脚本使用学习笔记(二)
参考文献 Shell 教程 MAC常用终端命令行 Mac下Shell脚本使用 (7)Shell echo命令: 命令格式:echo string ①显示普通字符串:echo "It is a ...
- Mac下Shell脚本使用学习笔记(一)
参考文献 Shell 教程 MAC常用终端命令行 Mac下Shell脚本使用 1.使用终端创建test.sh: (1)进入指定文件夹路径(命令示例:cd Desktop/面向对象程序设计): (2)创 ...
- mac下安装及配置tomcat
mac下的软件不像windows下的程序那样写注册表,对于tomcat的安装来说,在mac下是名符其实的绿色软件,具体操作如下: 1.到 apache官方主页 下载完整 tar.gz文件包.(没有专门 ...
- 2016年最新mac下vscode配置golang开发环境支持debug
网上目前还找不到完整的mac下golang环境配置支持,本人配置成功,现在整理分享出来. mac最好装下xcode,好像有依赖关系安装Homebrew打开终端窗口, 粘贴脚本执行/usr/bin/ru ...
- 【工匠大道】Mac下Java开发环境配置简述
本文地址 原文地址 分享提纲: 1. 下载JDK1.7 2. 配置java_home 3 .安装tomcat 4 .安装eclipse或者myeclipse 5. mysql安装 破解版下载请参考M ...
- Mac下的类似apt-get的包管理工具Homebrew(笔记)
对于一个习惯了在 Ubuntu 的终端上通过 apt-get 来安装工具软件的我来说,也希望在Mac上找到类似的工具,能很方便的一条命令就能安装所需的软件,而不用手工的去查找下载编译,或者是折腾安装所 ...
- Mac下各种网络命令的使用
Mac下各种网络命令的使用(http://blog.51yip.com/linux/745.html) pingwww.baidu.com 会一直ping下去,和windows不一样, windows ...
- Mac下python初学之Image库(PIL)
Mac下python 使用Image库 安装PIL,下载http://www.pythonware.com/products/pil/ 解压PIL源码包,阅读README知道需要使用python se ...
- Mac下安装 PIL
最近入手MacBook Pro 在配置PIL环境的时候遇到一些问题.现在把解决方式记录下来,希望对有需要的有所帮助. 1. 安装brew : brew 又叫Homebrew,是Mac OSX上的软件 ...
随机推荐
- EDK中如何使用ISE中生成的IP
EDK中如何使用ISE中生成的IP: 网上上有说这个的文章,但是很复杂,也就是添加bdd文件,其实这些都不需要自己操作的,我们可以在EDK中import 中添加ngc文件,ngc文件就是core ge ...
- cadence16.3破解方法
今天安装cadence16.3,安装了两遍都失败了,百思不得其解,结果总是出现在license上,如下图所示: 后面当然就只能启动demo版了,于是网上找,参照以前古老的法子,终于解决问题! 首先,开 ...
- php中echo、print、print_r、printf的返回值
1.echo 无返回值,是一个语言结构.在输出多个参数时不可以使用小括号; 2.print返回值为1:如:$x = 0; echo print $x."<br/>";/ ...
- Android Material Design的FloatingActionButton,Snackbar和CoordinatorLayout
如果是为了兼容低版本的Android系统,则需要引用Android Material Design的扩展支持库,我在之前的一篇文章张,较为详细的说明了如何导入Android Material Desi ...
- Use Sandcastle Help File Builder to generate help document
http://shfb.codeplex.com/ Note: If the the help file contains the text "[Missing <param> ...
- 每日一“酷”之Queue
Queue—线程安全的FIFO实现 作用:提供一个线程安全的FIFO实现 Queue模块提供了一个适用于多线程编程的先进先出(first-in,first-out)数据结构,可以用来在生产者和消费者线 ...
- php新手:XAMMP打开开源php代码
1.启动XAMPP 打开XAMPP启动 Apache 和 MySql 如果发现默认的80端口被IIS占用了 请参考 这个 如何改变apache被占用的端口 2.将源代码复制到 磁盘(XAMPP安装目 ...
- VS2010调试入门指南
1 导言 在软件开发周期中,测试和修正缺陷(defect,defect与bug的区别:Bug是缺陷的一种表现形式,而一个缺陷是可以引起多种Bug的)的时间远多于写代码的时间.通常,debug是指发现缺 ...
- CustomEditor 自定义预览窗
using UnityEngine; using System.Collections; public class MyTextureView : MonoBehaviour { public Tex ...
- Java线程同步(synchronized)——卖票问题
卖票问题通常被用来举例说明线程同步问题,在Java中,采用关键字synchronized关键字来解决线程同步的问题. Java任意类型的对象都有一个标志位,该标志位具有0,1两种状态,其开始状态为1, ...