首页 > mac 下周期调度命令或脚本

mac 下周期调度命令或脚本

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

更多相关:

  • 上篇笔记中梳理了一把 resolver 和 balancer,这里顺着前面的流程走一遍入口的 ClientConn 对象。ClientConn// ClientConn represents a virtual connection to a conceptual endpoint, to // perform RPCs. // //...

  • 我的实验是基于PSPNet模型实现二维图像的语义分割,下面的代码直接从得到的h5文件开始往下做。。。 也不知道是自己的检索能力出现了问题还是咋回事,搜遍全网都没有可以直接拿来用的语义分割代码,东拼西凑,算是搞成功了。 实验平台:Windows、VS2015、Tensorflow1.8 api、Python3.6 具体的流程为:...

  • Path Tracing 懒得翻译了,相信搞图形学的人都能看得懂,2333 Path Tracing is a rendering algorithm similar to ray tracing in which rays are cast from a virtual camera and traced through a s...

  • configure_file( [COPYONLY] [ESCAPE_QUOTES] [@ONLY][NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) 我遇到的是 configure_file(config/config.in ${CMAKE_SOURCE_DIR}/...

  •     直接复制以下代码创建一个名为settings.xml的文件,放到C:UsersAdministrator.m2下即可