notes on crontab including redirecting output

Kevin van Zonneveld has posted some notes on using crontab. I don’t use crontab enough, which means I always have to look up the time settings. However, that is easily done via Google. What I really liked about Kevin’s notes dealt with handling the errors and pointing them to a file rather than the user’s mailbox. I can see reasons for doing it either way.

5 thoughts on “notes on crontab including redirecting output

  1. Yeah, I have MRTG cron’ed on a machine to run every five minutes and when a host becomes unreachable I have a notice…every five minutes, lol.

  2. Yah… you don’t use cron ever because you use Windows, duh! For you it’s called “Task Scheduler,” 😛
    I hate email for log errors. Having some server send me an email is one more email in my inbox and is just one more email I have to delete. I would consider having it send by email if it went to an inbox for archival.

  3. I actually use cron on my Ubuntu boxes, but I also have it running on that Windows server in Cygwin. 🙂
    I like to email log errors to a ticket system of some sort, or to a box I actually will check. Sending them to some logging box means I’ll never check it. Sending them to my normal email, at least the important logs that I really want to know about asap if something is wrong, helps me see things quicker.
    I guess it’s more about alerts than just log files.

  4. I have an Exchange mailbox setup just for this purpose. I have all of my servers send their important data to it, such as:
    * My AV servers send their warnings about virus definitions expiring, quarantined emails, AV-specific services stopping, etc.
    * Backup server with details of the latest backup job.
    * Custom scripts that parse various syslog log files, download AV updates, etc. email their output to this box.
    * I use nullmailer on my Linux boxes and set the adminaddr to this email box so any email that’s supposed to go to root gets forwarded here. All other mailboxes are aliased to root.
    * HIDS output gets emailed here.
    Basically, this is my “to check constantly” mailbox and is added to the mail clients of the proper admins. Anything of importance is emailed to this box.
    I have also written a checklist that’s gone over every morning to verify that all expected email is present and how to handle each one.
    It’s a lot more convenient than spamming the department’s email list and the emails still get responded to in a short amount of time.

  5. Easy-peasy, just add the following line to the beginning of your personal crontab:
    #MIN HOUR DOM MON DOW /bin/execute/this/ >/dev/null 2>&1
    Then you’ll never forget. =)
    And don’t be shy about doing this one:
    crontab -l > crontab.txt
    And the other way is this:
    crontab crontab.txt

Comments are closed.