O'Reilly logo

The FreeBSD 6.2 Crash Course by Jem Matzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automation and Reporting

What good is an operating system if it can't perform automated tasks and create readable feedback that shows system activities? FreeBSD offers nothing above what most other Unix-like operating systems provide in these areas, so if you already have some experience with cron and syslog, you can probably skip this section—there's nothing new for you here.

The Cron Daemon

The cron implementation in FreeBSD is Vixie-cron, and is configured with the crontab command. Rather than reprint the information in the cron and crontab man pages, this guide will direct you to them.

The cron time format is as follows: minutes, hours, days, months, and day of the week. It also accepts plain English time formats such as @hourly, @daily, @weekly, @monthly, and @yearly. If you need something more specific or more frequent than hourly, you need to put your cron job into the aforementioned time format. For example, this example will run a custom PHP script that generates a sitemap of a web site hosted on this machine every day at 7:15 A.M.:

15 7 * * * /usr/local/bin/php /var/www/example.com/sitemap/runmap.php > /dev/null 2>&1

The "> /dev/null 2>&1" in the previous line will tell cron not to record or report the output of the script (or more accurately, it'll tell it to send the report to /dev/null). By default, cron will email the root account with any output from crontab entries. Putting this statement at the end of a line will ensure that you're not burdened by lengthy and unnecessary ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required