Posted by: jasonk2600 | November 24, 2009

Quickie HowTo – Cron Jobs Under FreeBSD

Cron is a simple, but powerful utility used to automate repetitive tasks that do not require any user interaction.  Most commonly, cron is used to run shell scripts to perform routine maintenance.  Utilizing cron jobs under FreeBSD is very simple.

To edit the cron jobs, logon as the user who’s cron jobs you want to edit and run the following:

# crontab -e

Below is an example of a cron job that is executed every 30 minutes.

*/30  *  *  *  *  /root/

The format of each cron job is as follows:

#minute  hour  day of month  month  day of week  command
*/30      *     *             *      *            /root/

An asterisks means that the job is run for every interval.  In the above example, the script /root/ is run every day of the week, every month, every day of the month, every hour, and every 30 minutes.  When specifying an interval, remember to begin with zero.  For example, to run a job every Sunday the day of the week would have to be set to 0.

To make administering cron jobs easier, one of the following strings can be used in place of all five of the time interval fields:

  • @reboot – Execute job at system boot only.
  • @yearly – Execute once a year (equivalent to 0 0 1 1 *).
  • @monthly – Execute once a month (equivalent to 0 0 1 * *).
  • @weekly – Execute once a week (equivalent to 0 0 * * 0).
  • @daily – Execute once a day (equivalent to 0 0 * * *).
  • @hourly – Execute every hour (equivalent to 0 * * * *).

For example, to run /root/ once a day enter the following into root’s crontab:

@daily  /root/




  1. nice… & useful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: