crontab 的格式备忘

经常用,但是经常忘记,基本的格式能记得,但是详细的或者复杂点的格式总会忘记或者拿不准,不知道是不是年纪大了记忆力下降,干脆整理出来今后方便查看。

基本格式 :
*  *  *  *  *  command
分 时 日 月 周 命令

第1列表示分钟1~59 每分钟用*或者 */1表示
第2列表示小时1~23(0表示0点)
第3列表示日期1~31
第4列表示月份1~12
第5列标识号星期0~6(0表示星期天)
第6列要运行的命令

crontab文件的一些例子:

30 21 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每晚的21:30重启lighttpd 。

45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每月1、10、22日的4 : 45重启lighttpd 。

10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每周六、周日的1 : 10重启lighttpd 。

0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示在每天18 : 00至23 : 00之间每隔30分钟重启lighttpd 。

0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每星期六的11 : 00 pm重启lighttpd 。

* */1 * * * /usr/local/etc/rc.d/lighttpd restart
每一小时重启lighttpd

* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart
晚上11点到早上7点之间,每隔一小时重启lighttpd

0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart
每月的4号与每周一到周三的11点重启lighttpd

0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart
一月一号的4点重启lighttpd

Category: Linux / BSD
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
29 Responses
  1. zhangzijian says:

    呵呵,为什么不把常用的,但记不住的东西打印出来,放在手边呢?其实也不是年龄大了,很多人都无法记住这些东西.

  2. Michael says:

    [Comment ID #13083 Will Be Quoted Here]

    嗯,言之有理,我之前就是整理了一些BSD系统各种应急处理方法,打印了放在笔记本包包里面,还真是用到了好几次。

  3. Javayou says:

    可是为什么要重启apache呢? 哈

    我习惯用的时候再来找,但是前提是知道有这么个东西

  4. Michael says:

    [Comment ID #13177 Will Be Quoted Here]

    哈哈,这个只是个例子而已了:)实际并不重启,我经常一个月也不用重启一次,现在服务器用的webServer是Nginx,不是Apache,你可以telnet后GET看看header,嘿嘿

  5. zhangzijian says:

    经常来你的blog看看.你是个挺有意思的人.如果能整理一套应急的方案,都可以奉献出来,给大家一块享用了。不过如果自己没有接触过,这些方案也就白白放在那里了.

  6. 南半球 says:

    good,最近我也在用,每天定时统计排行榜

  7. bssn says:

    这个是重启apache的?
    30 21 * * * /usr/local/etc/rc.d/lighttpd restart

    这不是重启lighttpd的吗?

    apache的我记得这样吧

    /sbin/service httpd restart

  8. Michael says:

    [Comment ID #18643 Will Be Quoted Here]

    哈哈,这个只是个书写的范例罢了,文章的主要目的不是为了记录这个,而是crontab的格式 🙂

  9. L0uiS says:

    0,1 * * * * /usr/L0uiS/Bishop/guard/AutoStartKFXGuard

    我这样写是每1分钟都执行一下这个(AutoStartKFXGuard)脚本吗??请回答!!!
    thx

  10. Michael says:

    [Comment ID #18849 Will Be Quoted Here]

    每小时的整点和每小时的第一分钟执行一次,不是每分钟,如果每分钟可以写成 * * * * * cmd 或者 */1 * * * * cmd 不过第二种方式在solaris下不生效,仅Linux下有效。

  11. L0uiS says:

    * * * * * cmd /usr/L0uiS/Bishop/guard/AutoStartKFXGuard

    是这样写吗??
    cmd是执行的意思???

  12. Michael says:

    对,cmd就是你要执行的命令

  13. L0uiS says:

    我能电话联系您吗??
    我非常着急!

  14. L0uiS says:

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly
    #AutoStartKFXGuard
    * * * * * /usr/L0uiS/bishop/AutoStartKFXGuard
    ~

    这里面应该怎么写?????????谢谢你

  15. L0uiS says:

    你在吗????
    我想开机掉用AutoStartKFXGuard这个脚本
    该如何写呢??????

    老问题,还是没有成功!
    谢谢你的耐心回答。。。

  16. L0uiS says:

    你在吗????
    我想每分钟掉用AutoStartKFXGuard这个脚本
    该如何写呢??????

    老问题,还是没有成功!
    谢谢你的耐心回答。。。

  17. L0uiS says:

    不是开机,是每分钟。不好意思

  18. Michael says:

    执行下列命令:
    # crontab -e

    加入这样一行
    * * * * * /usr/L0uiS/bishop/AutoStartKFXGuard

    保存退出 (:wq)

    完成

  19. zhusupe says:

    不错,多谢。

  20. 布布 says:

    正在找cron的资料,谢谢

  21. air max says:

    Exclusive: Melissa Gorga and Kathy Wakile Will Not air max shoes Be Spending Thanksgiving With Teresa Giudice!

  22. sacoche louis vuitton Saskatchewan multiple sclerosis patients hoping to take part in a clinical trial of a controversial treatment may soon get a call from the ministry of health.

  23. air yeezy 2012 Air Canada flights were set to stop this week after the airline said it would lock out its pilots and the machinists union said it would strike in the midst of the key spring holiday season.

  24. many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!!!

  25. To set the tone, Grace relied on the wisecracking snappy patter — “she gives as good as she gets,” Pearce says — between Emilie and Pearce’s agent.

  26. http://www.lovemichaelkors.com/ michael kors handbags
    Nice post, good to know that this topic is being covered also in this web site. Excellently written article, if only all blogger offered the same level of content as you.

  27. Thank you for an additional fantastic blog. michael kors storesWhere else might one get that sort of information written in such a perfect way?michael kors outlet I actually have a presentation that i am presently working on, and that i are looking for such information instead!michael kors handbags

  28. I am extremely impressed with your writing skills and also with the design of your blog. michael kors factoryIs this a paid theme or did you edit it yourself? Either way keep up the great quality writing, it is rare to see a nice website such as this one these days!

  29. ptc sites says:

    It’s an awesome paragraph in favor of all the online viewers;
    they will get advantage from it I am sure.

  30. You should take part in a contest for one of the
    greatest sites on the internet. I most certainly
    will recommend this website!

  31. Pretty sectgion of content. I just stumbled upon your site
    and inn accession capital to assert that I acquire in fact enjoyed account your blog posts.
    Anyway I will be subscribing to your augment
    and even I achievement you access consistently
    rapidly.

  32. ptc monitor says:

    Just want to say your article is as astounding. The clearness on your submit is
    simply excellent and that i could suppose you’re a professional on this
    subject. Fine together with your permission allow me to grab your
    RSS feed to keep up to date with drawing close post.
    Thank you 1,000,000 and please keep up the enjoyable work.

  33. Quality content is the important to be a focus
    for the visitors to pay a visit the web page, that’s what this web page is providing.

  34. minecraft says:

    I don’t know whether it’s just me or if everybody else experiencing issues with your website.

    It looks like some of the written text in your posts are running off the screen. Can someone else please
    comment and let me know if this is happening to them as well?
    This could be a issue with my browser because I’ve had this happen before.
    Appreciate it

  35. minecraft says:

    Very energetic blog, I liked that bit. Will there be a part 2?

  36. minecraft says:

    Just wish to say your article is as surprising.
    The clarity in your post is simply excellent and i could assume you are an expert
    on this subject. Fine with your permission allow me
    to grab your RSS feed to keep updated with forthcoming post.
    Thanks a million and please carry on the rewarding work.

  37. minecraft says:

    Thanks for your marvelous posting! I truly enjoyed reading it, you
    happen to be a great author. I will make sure to bookmark your blog and definitely will come
    back from now on. I want to encourage you to ultimately continue your great writing, have a nice holiday weekend!

  38. minecraft says:

    My relatives every time say that I am killing
    my time here at web, except I know I am getting familiarity all the time by reading such pleasant articles.

  39. minecraft says:

    Good day! I could have sworn I’ve been to this website before but after going through
    a few of the posts I realized it’s new to me. Nonetheless, I’m certainly
    happy I stumbled upon it and I’ll be bookmarking it and checking back
    frequently!

  40. minecraft says:

    If some one desires expert view about blogging afterward i propose him/her
    to visit this webpage, Keep up the fastidious work.

  41. minecraft says:

    Currently it sounds like BlogEngine is the best blogging platform available right now.
    (from what I’ve read) Is that what you’re using on your blog?

  42. minecraft says:

    An interesting discussion is worth comment. I believe that you should write more about
    this subject, it may not be a taboo subject but typically people don’t
    speak about these topics. To the next! All the best!!

  43. minecraft says:

    Usually I do not learn article on blogs, but I would like
    to say that this write-up very forced me to take a look at and
    do so! Your writing taste has been amazed me. Thank you, very nice post.

  44. minecraft says:

    I really like your blog.. very nice colors & theme. Did
    you create this website yourself or did you hire someone to
    do it for you? Plz answer back as I’m looking to design my own blog and would like to know where u got this
    from. thank you

  45. minecraft says:

    Woah! I’m really digging the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s very hard to get
    that “perfect balance” between user friendliness and appearance.
    I must say you’ve done a superb job with this.
    Also, the blog loads super quick for me on Safari. Outstanding Blog!

  46. minecraft says:

    bookmarked!!, I really like your site!

  47. minecraft says:

    An outstanding share! I’ve just forwarded this onto a coworker
    who was doing a little research on this. And he in fact ordered me
    lunch due to the fact that I found it for him…
    lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to discuss this issue here on your
    site.

  48. minecraft says:

    I’m really enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often.
    Did you hire out a designer to create your theme?
    Superb work!

  49. minecraft says:

    Thanks for sharing your thoughts about minecraft.
    Regards

  50. minecraft says:

    Hello there! This article could not be written any
    better! Going through this post reminds me of my previous roommate!
    He always kept talking about this. I’ll forward this article to him.
    Fairly certain he’s going to have a very good read. Thanks for sharing!

  51. I pay a visit day-to-day a few sites and blogs to read articles
    or reviews, however this website presents quality based posts.

  52. Do you have a spam problem on this blog; I also am a blogger, and I was wanting to know your situation; we have developed some nice methods and we are looking to trade strategies with other folks, be sure
    to shoot me an email if interested.

  53. You need to be a part of a contest for one of the most useful blogs online.
    I’m going to highly recommend this blog!

  54. If you want to grow your know-how only keep visiting this web page and be updated with the hottest news posted here.

  55. Keep in mind that the starting heap measurement
    may be the same for several at the beginning of the contest.

  56. First of all I would like to say superb blog!
    I had a quick question in which I’d like to ask if you do not mind.
    I was interested to find out how you center yourself and clear your mind prior to writing.
    I’ve had a difficult time clearing my mind in getting my thoughts out there.

    I do take pleasure in writing but it just seems like
    the first 10 to 15 minutes are usually lost simply just trying to
    figure out how to begin. Any recommendations or hints? Thanks!

  57. Hi it’s me, I am also visiting this website daily, this website is actually fastidious and
    the users are truly sharing pleasant thoughts.

  58. Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is valuable and everything. However just imagine if you
    added some great images or video clips to give your posts more, “pop”!
    Your content is excellent but with images and video clips,
    this website could undeniably be one of the greatest in its niche.

    Superb blog!

  59. Hi there! This is kind of off topic but I need some guidance from an established blog.
    Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about making my own but I’m not sure where to begin. Do you have any tips or
    suggestions? Many thanks

  60. Hi there it’s me, I am also visiting this web site regularly, this website is in fact
    good and the people are really sharing good thoughts.

  61. Sling TV says:

    I am regular visitor, how are you everybody? This post posted at
    this web page is genuinely pleasant.

  62. Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is valuable and everything.
    However imagine if you added some great graphics or videos to give your posts more,
    “pop”! Your content is excellent but with images and video clips, this website could definitely
    be one of the best in its niche. Fantastic blog!

  63. Thanks for your personal marvelous posting! I quite enjoyed
    reading it, you can be a great author.I will be sure to bookmark your
    blog and may come back someday. I want to encourage
    yourself to continue your great writing, have a nice afternoon!

  64. Heya! I just wanted to ask if you ever have any issues with hackers?
    My last blog (wordpress) was hacked and I ended up losing
    months of hard work due to no data backup. Do you have any methods to prevent
    hackers?

  65. ladyboy says:

    You really make it seem so easy with your presentation but
    I find this topic to be actually something that I think I would never understand.
    It seems too complex and very broad for me. I’m looking forward for your next post, I will try to get the hang
    of it!

  66. I blog often and I genuinely appreciate your content. This great article has really peaked my interest.

    I will bookmark your website and keep checking for new information about once per week.
    I subscribed to your Feed too.

  67. Pingback: Weselne
  68. Hi, I think your blog might be having browser compatibility
    issues. When I look at your website in Chrome, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!
    Other then that, very good blog!

  69. minecraft says:

    I’m extremely pleased to uncover this great site. I need
    to to thank you for your time just for this wonderful
    read!! I definitely really liked every bit of it and I have you book-marked to check out new stuff on your website.

  70. I got this web site from my pal who informed me about this website
    and at the moment this time I am browsing this web site and reading very
    informative articles at this place.

  71. minecraft says:

    Saved as a favorite, I really like your website!

  72. minecraft says:

    Having read this I believed it was very informative.
    I appreciate you finding the time and energy to put this information together.

    I once again find myself spending a significant amount
    of time both reading and posting comments. But so what, it was still
    worthwhile!

  73. tinyurl.com says:

    I love your blog.. very nice colors & theme. Did you create this website
    yourself or did you hire someone to do it for you?
    Plz answer back as I’m looking to create my own blog and would like to
    find out where u got this from. many thanks

  74. tinyurl.com says:

    These are actually enormous ideas in regarding blogging.
    You have touched some pleasant points here.
    Any way keep up wrinting.

  75. minecraft says:

    Its like you read my mind! You seem to know so much about
    this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message
    home a little bit, but other than that, this is great blog.
    A great read. I’ll certainly be back.

  76. minecraft says:

    Undeniably believe that which you said. Your favorite justification appeared to
    be on the internet the easiest thing to be aware of. I say to you, I certainly get irked while people think about
    worries that they just don’t know about. You managed to hit
    the nail upon the top as well as defined out the
    whole thing without having side effect , people
    can take a signal. Will probably be back to get more.
    Thanks

  77. gamefly says:

    Howdy! I could have sworn I’ve been to this web
    site before but after going through some of the articles I realized it’s new to me.
    Nonetheless, I’m definitely happy I found it and I’ll be bookmarking it and checking back often!

  78. Pingback: sex xvideos
  79. Hello! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but
    I’m not seeing very good success. If you know of any please share.
    Many thanks!

  80. Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an email.
    I’ve got some ideas for your blog you might be interested in hearing.
    Either way, great website and I look forward to seeing it expand over time.

  81. Hi there would you mind stating which blog platform you’re working with?
    I’m looking to start my own blog in the near future but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and style seems different then most blogs
    and I’m looking for something unique.
    P.S Sorry for being off-topic but I had to ask!

  82. g says:

    We stumbled over here coming from a different page and thought I may as well check things out.
    I like what I see so i am just following you.
    Look forward to checking out your web page repeatedly.

  83. I was very pleased to find this website. I
    wanted to thank you for your time for this particularly fantastic read!!
    I definitely appreciated every bit of it and i also have you
    book marked to see new information on your web site.

  84. We are a group of volunteers and opening
    a new scheme in our community. Your website provided us with valuable information to work on. You have done
    a formidable job and our whole community will be thankful to you.

  85. If some one wishes to be updated with most recent technologies then he must be go to see this site and be
    up to date daily.

  86. Hi, I check your blog daily. Your writing style is awesome, keep it
    up!

  87. These are in fact enormous ideas in regarding blogging.
    You have touched some pleasant factors here. Any way keep up wrinting.

  88. I’m not that much of a online reader to be honest but your
    sites really nice, keep it up! I’ll go ahead and bookmark your website to
    come back later. Cheers

  89. Hey there I am so glad I found your web site, I really
    found you by accident, while I was browsing on Bing for something else, Regardless
    I am here now and would just like to say thanks a lot
    for a fantastic post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have book-marked it and also added
    in your RSS feeds, so when I have time I will be back to read a
    great deal more, Please do keep up the superb job.

  90. Very nice post. I just stumbled upon your weblog and wanted to say that I’ve truly enjoyed browsing your blog posts.
    After all I will be subscribing to your rss feed and I hope you write again very soon!

  91. Hey there this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding experience so
    I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

  92. Do you have a spam issue on this site; I also am a blogger,
    and I was wondering your situation; many of us have created some nice
    methods and we are looking to exchange methods with others,
    be sure to shoot me an e-mail if interested.

  93. You’ve made some decent points there. I checked on the net for more info about the issue and found most people will go along with your views on this website.

  94. What’s Going down i’m new to this, I stumbled upon this I have discovered It positively helpful and it has aided me out loads.
    I hope to give a contribution & help different users like its helped me.
    Good job.

  95. pof says:

    What’s up to all, how is all, I think every one is getting more from this website, and your views are fastidious in favor of new
    viewers.

  96. This site certainly has all of the information I needed about this subject and didn’t know who to ask.
    natalielise pof

  97. Hi there colleagues, how is the whole thing, and what you wish for to say about this piece of writing,
    in my view its actually awesome designed for me.hot free porn

  98. whoah this weblog is wonderful i like reading your posts.
    Stay up the great work! You realize, lots of persons are searching round for
    this info, you could help them greatly.

  99. Charlespek says:

    Good posts. Cheers.
    canadian discount pharmacy
    london drugs canada
    canada drugs online
    best 10 online canadian pharmacies
    ed meds online without doctor prescription – https://www.canadianpharmacy-ltd.com/

    best 10 online canadian pharmacies hing 6442241

  100. Currently it sounds like Movable Type is the top blogging platform available right now.
    (from what I’ve read) Is that what you are using on your blog?

  101. I love your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone
    to do it for you? Plz respond as I’m looking to design my own blog and would like
    to know where u got this from. many thanks

  102. I used to be recommended this web site by way of my cousin.
    I am now not certain whether or not this put up is written via him as no one else know such designated about my trouble.
    You are amazing! Thank you!

  103. Do you mind if I quote a couple of your articles as
    long as I provide credit and sources back to your blog? My blog is in the exact same niche
    as yours and my visitors would certainly benefit from a lot of the information you present here.
    Please let me know if this okay with you. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image