What Is the Difference Between Cron & Anacron?

Save

Unix-based operating systems rely on a pair of programs to schedule maintenance and other jobs. The base scheduling program is “cron,” while its counterpart “anacron” handles specific duties that cron cannot. Together, these two applications allow users to ensure that important tasks run on schedule, or at least as close to on schedule as the system allows.

Cron

  • Cron allows users to schedule tasks for very specific times. All applications of cron can schedule tasks to the minute, and some implementations even allow users to pinpoint the precise second at which the system should begin the action. Tasks can run on specific dates, or recur at periods as small as every minute. Cron also allows users in large, national systems to designate the time zone under which their tasks fall, to ensure proper execution using local times.

Anacron

  • Cron is suitable for most tasks, but its biggest weakness is that it ceases to function if the system goes down. If you schedule a task for a specific date and the system is down on that date, the task will never execute. Anacron, a companion process to cron, allows you to schedule tasks that will run on either a specified date or the first available cycle after that date. Anacron only allows daily scheduling, forcing users who need tighter scheduling to rely on cron for their tasks.

Syntax

  • Cron and anacron rely on “table” files, each of which contains a list of tasks preceded by a series of numbers. The first number represents the minute the task should begin, while the second represents the hour in military time. “0 0” would represent midnight, while “30 17” would run at 5:30 PM. The third number represents the day of the month, and the fourth the month itself. The fifth digit allows users to schedule for a specific day of the week, ranging from zero for Sunday to six for Saturday. Placing an asterisk in any field forces the system to disregard that field in the case of weekdays, or to run the task at every available interval. An asterisk in the fourth field would run the task every month on the specified day, while an asterisk in all five would result in a task executed every single minute.

Other Variations

  • As many different operating systems have come from the basic Unix system, many different versions of cron and anacron exist. One popular alteration allows users to use three-letter designations for weekdays and months instead of numeric ones. Some implementations also allow the use of mathematical expressions, such as “/5” in the minute field designating a task every five minutes, or “/2” in the day field scheduling a task for every other day.

References

Promoted By Zergnet

Comments

Related Searches

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!