mac 下周期调度命令或脚本
生活随笔
收集整理的這篇文章主要介紹了
mac 下周期调度命令或脚本
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
crontab 是在linux服務(wù)器上部署定時任務(wù)的方法0 5 * * * /usr/bin/python /data/www/tools/mysql_backup.pycmd之前有5個項目要填,分別對應(yīng)分鐘 小時 天 月 一周當(dāng)中第幾天( 0-6 ,0表示星期天)填寫方法* 表示都滿足,例如 * * * * * 表示每分鐘執(zhí)行一次,如果每小時執(zhí)行一次,那應(yīng)該這樣寫
1 * * * * (每小時第一分鐘執(zhí)行,1可以隨便改成60以內(nèi)的數(shù)字)
/n 表示隔n個單位執(zhí)行一次
/3 * * * * 3分鐘執(zhí)行一次
1 */3 * * * 表示每隔3個小時的第一分鐘執(zhí)行一次
1 1 */3 * * 表示每隔3天,當(dāng)天的1點1分執(zhí)行一次
1 12 * * 2,3,4,5,6 表示每周二到周6,每天中午12點1分執(zhí)行
只需要掌握這2種時間用法,crontab就ok了提示:crontab 最小粒度是一分鐘執(zhí)行一次,要更快,得用其它辦法,比如說寫一個daemon程序,用while true: 來做
crontab -l 查看所有crontab 列表
cronta -e 編輯crontab
crontab條目是以文件方式存儲的,可以用ls /etc/cron* 查看
標(biāo)簽: linuxcrontab本文地址: http://lutaf.com/51.htm 魯塔弗原創(chuàng)文章,歡迎轉(zhuǎn)載,請附帶原文鏈接
?
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/*** 目錄下發(fā)送郵件 append方式, 不知道別人怎么樣,在mac環(huán)境下不會出現(xiàn)這種情況,除非 ****** cmd , cmd 有運(yùn)行錯誤,就會輸入到/var/mail/*** 里面。
?
轉(zhuǎn)載于:https://www.cnblogs.com/IamThat/p/4360794.html
總結(jié)
以上是生活随笔為你收集整理的mac 下周期调度命令或脚本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 北京茶叶蛋多少钱一个
- 下一篇: 四种DCOM错误的区别,0x800800