How to write a cron that will run a script every day at midnight?

前端 未结 6 1294
予麋鹿
予麋鹿 2020-11-28 02:21

I have heard crontab is a good choice, but how do I write the line and where do I put it on the server?

6条回答
  •  执念已碎
    2020-11-28 02:44

    Here's a good tutorial on what crontab is and how to use it on Ubuntu. Your crontab line will look something like this:

    00 00 * * * ruby path/to/your/script.rb
    

    (00 00 indicates midnight--0 minutes and 0 hours--and the *s mean every day of every month.)

    Syntax: 
      mm hh dd mt wd  command
    
      mm minute 0-59
      hh hour 0-23
      dd day of month 1-31
      mt month 1-12
      wd day of week 0-7 (Sunday = 0 or 7)
      command: what you want to run
      all numeric values can be replaced by * which means all
    

提交回复
热议问题