Wednesday, March 22, 2006

Cron with Linux

My wife wants some tasks to be done at our LAN in a very precise moments of the day. Sure, I say, and then came to my mind that I never remember how to write cron configuration lines. I even consider to writte a short post about essentials, but, as soon as I've a look on the Internet I found so good documentation that it would useless to writte it.

One of most simple explanation that I need to keep here is that from RH:

  • minute ? any integer from 0 to 59
  • hour ? any integer from 0 to 23
  • day ? any integer from 1 to 31 (must be a valid day if a month is specified)
  • month ? any integer from 1 to 12 (or the short name of the month such as jan, feb, and so on)
  • dayofweek ? any integer from 0 to 7 where 0 or 7 represents Sunday (or the short same of the week such as sun, mon, and so on)
  • command ? the command to execute. The command can either be a command such as ls /proc >> /tmp/proc or the command to execute a custom script that you wrote.

I'd remembered that cron from Linux is slightly different from other Unixes; Linux has a field that lets you specify wich user is goin to run the command. Linux also, has an special cron called anacron wich is mainly the same as cron but oriented to computers that aren't running continously, such as laptop.

You may also have a look on this helpful links: