System managementBeginner24 min read

What Does anacron Mean?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

Anacron is like a backup scheduler for your computer. It makes sure that important tasks, like cleaning up temporary files or running a security scan, still happen even if your computer was shut down or asleep when they were supposed to run. Unlike the regular cron scheduler, anacron checks what tasks you missed and runs them soon after you turn your computer back on.

Commonly Confused With

anacronvscron

Cron schedules tasks at precise times (e.g., 2:30 PM every Friday) and requires the system to be on at that moment. Anacron schedules tasks based on elapsed days and runs them as soon as the system is on after the period expires. Cron is for always-on servers; anacron is for desktops and laptops.

Cron: Run backup at 3:00 AM daily. Anacron: Run backup every 1 day, but anytime after the system is turned on.

anacronvssystemd timers

Systemd timers are a modern replacement for cron and anacron in many Linux distributions. They can schedule tasks with both calendar events (like cron) and monotonic timers (like anacron, e.g., 'run 5 minutes after boot'). Systemd timers are more powerful but also more complex to configure than anacron.

An anacron job '1 5 job /cmd' is equivalent to a systemd timer with OnBootSec=5min and OnUnitActiveSec=1 day.

anacronvsat command

The at command schedules a one-time task to run at a specific future time. Anacron is for recurring tasks. Once an at job runs, it is removed. Anacron repeatedly runs jobs as long as the configuration remains.

Use 'at 3pm tomorrow' for a one-time reminder. Use anacron for 'run this every day.'

Must Know for Exams

For general IT certifications, anacron is not a heavy focus, but it does appear as a supporting concept, especially in exams that cover Linux system administration fundamentals. Exams such as CompTIA Linux+ (XK0-005), LPIC-1 (101 and 102), and the Red Hat Certified System Administrator (RHCSA) may include questions about scheduling tasks on systems that are not always on. In CompTIA Linux+, for instance, the exam objectives include 'Schedule tasks using cron and anacron.' Similarly, LPIC-1 objective 108.1 covers 'maintaining system time and running jobs in the future,' and anacron is explicitly listed.

The typical exam question patterns are:

- Comparison questions: 'What is the difference between cron and anacron?' The expected answer is that cron relies on the system being on at the scheduled time, while anacron runs missed jobs after the system resumes. - Scenario questions: 'A user reports that daily log rotation jobs are not running on their laptop that is often shut down. What should you use?' The correct answer will be anacron, or editing /etc/anacrontab. - Configuration questions: 'Which file is used to configure anacron jobs?' The answer is /etc/anacrontab (or /etc/cron.d/anacron depending on distribution). - Behavior questions: 'What happens if anacron cannot run a job because the system is off?' Answer: 'The job will be queued and run when the system is back on, after a specified delay.'

In the LPIC-1 exam, you might also be asked about the format of anacrontab entries. For example, the fields: period in days, delay in minutes, job identifier, and command. You may be asked to identify the correct line to run a backup every 7 days with a 10-minute delay after startup.

exam questions can test your understanding of the interplay between cron and anacron. Many modern distributions run cron jobs from the /etc/cron.daily directory via anacron. A typical exam trap: 'You place a script in /etc/cron.daily but it never runs. Why?' The answer might involve checking that anacron is enabled and has the correct timer configured. Understanding that anacron is the mechanism that actually triggers these daily scripts is crucial.

For these exams, you should also know that anacron does not replace cron entirely. Some tasks require exact timing that anacron cannot provide (e.g., a job must run at 9:15 AM every Tuesday). Remembering this distinction helps in answering 'choose the best tool' questions.

for general IT certifications, anacron appears in about 1-3 questions, often embedded in broader scheduling topics. Mastery of the basic comparison with cron, the file location, and the simple configuration syntax is sufficient.

Simple Meaning

Imagine you have a cat that needs to be fed every morning at 7 AM sharp, but sometimes you have to leave for work before 7 AM. A regular scheduler would try to feed the cat at 7 AM whether you're home or not, but if you're gone, the cat doesn't get fed. Anacron is like having a smart neighbor who notices you were gone and feeds the cat at 8 AM instead, as soon as you get back. It doesn't care about the exact time, it just makes sure the job gets done.

In the computer world, many routine maintenance tasks are set to run at specific times using a program called cron. Cron works well for servers that are on 24/7, but it fails if the computer is turned off during that time. Anacron fills that gap by keeping track of when a job was last run and running it if too much time has passed. For example, if a log cleanup task is set to run daily at midnight but your laptop is asleep, anacron will run it when you wake the laptop the next morning.

Anacron does not use exact times like 3:00 PM. Instead, it uses delays in days, weeks, or months. You tell it to run a job every 7 days, and it will run it whenever the computer is on after those 7 days are up. This makes it perfect for laptops and desktop computers that get shut down regularly. Anacron is simple, reliable, and takes the stress out of missing scheduled maintenance on personal or non-critical systems.

Full Technical Definition

Anacron is a task scheduler for Unix-like operating systems, designed specifically for machines that are not continuously powered on or are frequently shut down. It addresses a fundamental limitation of the traditional cron daemon, which assumes the system is always running and schedules jobs based on absolute wall-clock times (e.g., every Tuesday at 3:00 AM). When a cron job’s scheduled time passes while the system is off, cron has no mechanism to retroactively execute that job. Anacron solves this by scheduling jobs based on elapsed time since the last execution, not on a fixed calendar date or time.

Anacron reads its configuration from the file /etc/anacrontab (or /etc/cron.d/anacron on some distributions). The format uses three fields: period in days, delay in minutes, job-identifier, and command. For example: '7 5 logcleanup /usr/bin/log-clean'. This means: run the command every 7 days; if the system is off when the 7th day passes, wait 5 minutes after boot before running it; and use the identifier 'logcleanup' to track its last-run timestamp. Anacron stores timestamps in the /var/spool/anacron directory, one file per job identifier. These timestamp files record the last date (in epoch days) that a job was executed.

On system startup, anacron is typically triggered by an init script or systemd service (e.g., anacron.service on modern Linux distributions). It compares the current date (converted to days since the epoch) with the timestamp stored for each job. If the difference equals or exceeds the configured period, anacron waits the specified delay (to allow other boot processes to finish) and then runs the command. It updates the timestamp file only after the job completes successfully. If the job fails or is interrupted, anacron may be configured to not update the timestamp, causing the job to re-run on the next anacron invocation.

A critical distinction from cron is that anacron does not support specifying exact hours or minutes; its granularity is days. This makes it unsuitable for tasks that must run at a precise time, such as billing batch jobs at midnight. Anacron runs jobs sequentially within a single anacron process, no concurrency. This can cause delays if one job takes a long time. Most modern Linux distributions combine cron (for precise timings on always-on servers) with anacron (for daily, weekly, or monthly maintenance jobs on desktops). For instance, the popular package 'cronie' includes both cron and anacron integrated, so jobs in /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly are handled by anacron while hourly jobs remain with cron.

Anacron also has limitations. It does not handle jobs that need to run multiple times within a single day. It cannot schedule jobs at specific minutes or hours. It also does not handle time zone changes or daylight saving time transitions gracefully, it relies on the system's local time, which can cause jobs to run an hour early or late. Despite these constraints, anacron is a robust solution for non-critical periodic maintenance on systems that are not always on, and it is widely used in consumer Linux distributions like Ubuntu, Fedora, and Debian.

Real-Life Example

Think about how you take out the trash. Your city picks up trash every Tuesday morning at 8 AM. If you are home every Tuesday, you can reliably put the bins out on Monday night. But what if you travel for work and are sometimes gone for a whole week? The regular schedule fails, the trash stays inside, and you have to wait another week. Now imagine a neighbor who watches your house. Every Tuesday, they check if your bins are out. If you are away, they do nothing on Tuesday. But on Wednesday morning, the moment they see your car in the driveway, they knock on your door and say, 'Hey, you missed trash day. Please put your bins out now. I will call the city to do a special pickup this afternoon.' That neighbor is anacron. They do not operate on a rigid clock, they operate on the idea of 'as soon as you return, take care of what was missed.'

This analogy maps directly to IT. The trash pickup is a scheduled system job (like rotating log files, updating virus definitions, or compressing old databases). The city schedule is cron, fixed to a day and time. The neighbor is anacron, which knows that the job was supposed to happen every 7 days, and when the computer comes back online after more than 7 days have passed, it runs the job after a short delay. The delay (like the neighbor giving you 10 minutes to unpack) allows other startup processes to complete. The timestamp file is like the neighbor’s notebook, they write down the last time you took out the trash. If you took it out Tuesday, they mark 'done' and don't bother you until the following Tuesday. If you miss it, they nag you when you get back.

In a real IT environment, an anacron job might be set to run a backup of your home folder every 7 days. If you shut down your laptop for a 10-day vacation, cron would simply not run the backup. Anacron, however, will run the backup 5 minutes after you power on your laptop on day 11, ensuring your data is protected.

Why This Term Matters

In the enterprise world, servers are typically left running 24/7, and cron is the perfect scheduler for them. But IT professionals also manage workstations, laptops, virtual desktops, and development sandboxes that are frequently shut down or put to sleep. On these machines, relying solely on cron creates a maintenance gap: critical tasks like log rotation, temporary file cleanup, system updates, security scans, and database vacuuming can be missed indefinitely, leading to security vulnerabilities, disk space exhaustion, or degraded performance.

Anacron bridges that gap. By ensuring that important housekeeping tasks catch up, anacron helps maintain system health even on intermittently used machines. For example, a developer who shuts down their Linux workstation every evening still needs daily virus definition updates and weekly disk cleanup. Without anacron, these tasks would never run if the workstation was off at 3:00 AM when cron scheduled them. With anacron, the tasks run as soon as the developer boots up the next morning.

anacron is often used in embedded systems and IoT devices that may not have persistent power. A solar-powered sensor that only turns on during daylight hours might rely on anacron to handle daily data compression and upload tasks. In these scenarios, cron is simply not an option, and anacron becomes essential for reliable system administration.

From a certification perspective, understanding anacron shows that you know the real-world limitations of cron and the tools available to compensate. It demonstrates practical thinking about system management, especially for systems that are not always-on servers. For general IT certifications, this knowledge is important because many questions and job situations involve mixed environments where both always-on and intermittently-on systems coexist.

How It Appears in Exam Questions

Anacron appears in certification exams through several distinct question patterns designed to test both conceptual understanding and practical configuration knowledge.

First, there are direct comparison questions. These often come in multiple-choice format: 'Which of the following tools would you use to ensure a daily system backup runs even if the computer is turned off at the scheduled time?' The options typically include cron, anacron, at, and systemd timers. The correct answer is anacron because it catches up on missed jobs. A variation might ask about the limitations of cron, such as 'A system administrator notices that a weekly log cleanup job defined in crontab does not run on a laptop that is often shut down. Why?' Answer: Because cron requires the system to be powered on at the exact scheduled time.

Second, there are configuration and troubleshooting scenarios. An exam question might present a partial anacrontab file: '7 15 cleanup /usr/local/bin/cleanup.sh' and ask what each field does. The answer: 'Run the script every 7 days, with a 15-minute delay after starting the system.' Another scenario: 'After configuring a job in /etc/anacrontab, the job still does not run. What should the administrator check?' Possible answers include: verifying that the anacron service is enabled, checking the spool directory for timestamp files, or confirming that the job identifier is unique and correctly spelled.

Third, exams may ask about the job processing behavior of anacron. For instance: 'An anacron job with a period of 1 day is configured. The system is turned off for 3 days. When the system is turned on, how many times will the job run?' The correct answer is 'once,' because anacron only cares whether at least one day has passed, and it runs the job only once after the delay, not once for each missed day.

Fourth, there are combined cron-and-anacron questions. A question might show a crontab entry for a daily job and a separate anacron entry for the same script, and ask which one will take effect. The trick is that cron and anacron are independent, both could run the job, so the administrator must disable the other. Another common question: 'Where are the scripts for daily, weekly, and monthly jobs stored?' Answer: /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly. But then a follow-up: 'What runs these scripts on a typical Ubuntu system?' Answer: anacron, via the /etc/crontab entry that calls run-parts with anacron.

Finally, some questions test knowledge of anacron's file locations. You might be asked: 'In which directory does anacron store the timestamps that track when a job was last run?' The answer is /var/spool/anacron. Another: 'What is the default configuration file for anacron?' Answer: /etc/anacrontab. These are straightforward memory questions that reward familiarity with standard Linux paths.

For the best preparation, practice reading anacrontab entries, explaining the behavior when a system is offline for 10 days, and distinguishing between anacron and cron in various scenarios.

Study CompTIA Linux+

Test your understanding with exam-style practice questions.

Practise

Example Scenario

A small company uses a Linux file server that is shut down every evening to save power. The IT administrator, Maria, wants a system log cleanup script to run daily to prevent the log files from filling up the hard drive. She sets up a cron job to run at midnight. After a week, Maria notices that the log files are still growing because the server is never on at midnight. The cron job has never run once.

Maria then switches to anacron. She adds the following line to /etc/anacrontab: '1 10 logcleanup /usr/local/sbin/cleanup_logs.sh'. This tells anacron to run the script every day (period of 1), with a delay of 10 minutes after the system starts. The job identifier is 'logcleanup'.

Now, every morning when Maria turns on the file server at 8:00 AM, anacron checks the timestamp file for 'logcleanup' in /var/spool/anacron. It finds that the last run was yesterday, so at least one day has passed. It waits 10 minutes (until 8:10 AM) to allow other boot processes and services to start, then executes cleanup_logs.sh. The log files are cleaned daily without fail.

One Monday morning, Maria takes a long weekend and the server is off from Friday 5:00 PM until Tuesday 8:00 AM. That means three full days pass. On Tuesday at 8:10 AM, anacron sees that the timestamp is from Friday morning, so three days have elapsed, which is more than the 1-day period. It runs the job once. The logs are cleaned, and the timestamp is updated to Tuesday. The job does not run three separate times for each missed day, anacron only cares that the period has been met.

This scenario illustrates why anacron is ideal for non-24/7 systems. Maria does not need to worry about precise timing; she only needs to set a period and a delay. The system automatically catches up on missed executions, maintaining system health without manual intervention.

Common Mistakes

Thinking anacron and cron are interchangeable for all scheduling needs.

Anacron cannot schedule tasks at a specific hour or minute; it only supports daily, weekly, or monthly granularity. Cron is required for precise time-based scheduling.

Use cron when exact timing matters (e.g., 3:15 PM on Tuesdays). Use anacron for periodic maintenance that can run anytime after a delay.

Believing anacron will run a job multiple times if multiple periods are missed.

Anacron tracks only whether the period has been exceeded, not how many times it was missed. It runs the job only once after the system is back online.

Understand that anacron's logic is: if the current day minus last run day >= period, run once. It does not accumulate missed runs.

Assuming anacron uses the same configuration file format as cron.

Cron uses crontab with five time fields (minute, hour, day, month, weekday). Anacron uses anacrontab with only a period in days, a delay in minutes, a job ID, and a command.

Learn the distinct anacrontab syntax: period delay job-identifier command. No hour/minute fields.

Thinking anacron updates the timestamp file before the job runs or even if the job fails.

Anacron updates the timestamp only after the job completes successfully. If the job fails or crashes, the timestamp is not updated, and anacron will attempt to run it again on the next invocation.

Always ensure jobs are reliable or include error handling. Check /var/spool/anacron if jobs appear to run repeatedly.

Forgetting that anacron runs jobs sequentially, not in parallel.

If multiple jobs are configured in anacrontab, anacron processes them one by one. A long-running job can delay subsequent jobs significantly.

Keep anacron jobs short and lightweight. For tasks that take hours, consider using cron with proper timing instead.

Exam Trap — Don't Get Fooled

{"trap":"An exam question shows an anacrontab line with a period of 0 days (e.g., '0 10 job /run.sh') and asks what will happen.","why_learners_choose_it":"Learners may think '0' means run immediately, or they may confuse it with a cron syntax where 0 means a specific minute.

They may also think a 0 period means it runs every boot.","how_to_avoid_it":"Remember that anacron periods represent days. A period of 0 is not meaningful because it would mean run every 0 days, which would cause the job to run every time anacron runs.

In practice, anacron will still run the job because the condition (0 days passed) is always true, but it is illogical and not used. The exam expects you to recognize that anacron periods must be positive integers (1 or greater). Zero is not a valid period for normal use.

Instead, the concept of 'run on every boot' is handled by cron's @reboot directive, not by anacron."

Step-by-Step Breakdown

1

System Boot

The computer is turned on or woken from sleep. The operating system starts all services, including the anacron daemon (anacron.service) if it is enabled.

2

Anacron Invocation

Anacron starts reading its configuration file, typically /etc/anacrontab. It lists all configured jobs along with their period (in days), delay (in minutes), identifier, and command.

3

Timestamp Check

For each job, anacron opens the corresponding timestamp file in /var/spool/anacron. The filename is the job identifier. It reads the last run date stored as a number of days since the Unix epoch.

4

Period Comparison

Anacron calculates the difference between the current date (in days since epoch) and the last run date. If the difference is equal to or greater than the job's configured period, the job is considered due for execution. If not, anacron skips that job and moves to the next.

5

Delay Wait

If the job is due, anacron waits for the configured delay (in minutes). This allows the system to finish booting and for other startup services to stabilize before the job runs. During this wait, anacron does nothing else.

6

Job Execution

After the delay expires, anacron runs the command specified in the anacrontab entry. The job runs with the privileges of the user that owns the anacron process (usually root). Anacron waits for the command to complete.

7

Timestamp Update

If the command exits with a zero exit status (success), anacron updates the timestamp file in /var/spool/anacron with the current date. If the command fails (non-zero exit status), the timestamp is not updated, so anacron will try the job again on the next invocation.

8

Next Job Processing

Anacron proceeds to the next job in the configuration file. All jobs are processed sequentially, no parallel execution.

Practical Mini-Lesson

Anacron is a tool that every Linux system administrator should understand, even if they primarily work on always-on servers, because administrative tasks often involve mixed environments. In practice, anacron is rarely used standalone; it is usually integrated into the system's cron setup. On most Debian-based and Red Hat-based distributions, the /etc/crontab file includes a line that runs the scripts in /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly using run-parts with anacron. This means that when you drop a script into /etc/cron.daily, you are actually relying on anacron to execute it.

Professionals need to know how to customize anacron behavior beyond defaults. For example, you might want to add a custom job that runs every 3 days with a 15-minute delay after boot. You simply edit /etc/anacrontab and add a line like: '3 15 customjob /usr/local/bin/my_custom_script.sh'. You must then create a dummy timestamp file in /var/spool/anacron named 'customjob' with an old date to force immediate execution on next boot. If you forget the timestamp file, anacron will create it automatically after the first run.

What can go wrong? Common issues include:

- Job never runs: Check that anacron service is enabled (systemctl enable anacron). Also check that the timestamp file exists and is readable. Sometimes a permissions problem on /var/spool/anacron can prevent anacron from writing timestamps, causing it to skip jobs. - Job runs too often: This can happen if the period is set too low (e.g., 1 day) and the system is turned on multiple times a day. Anacron will run the job each time it sees 1 day has passed, which might be every boot. Solution: increase the period or use cron @daily for true daily timing. - Job runs with wrong environment: Anacron jobs run in a minimal environment. If your script depends on PATH or specific shell variables, you may need to set them inside the script or source a profile. Always test the script manually first. - Delay not working as expected: The delay is in minutes and applies only to the first run after boot. If the job fails to update the timestamp (due to script failure), the next boot will also trigger the same job with the delay again.

For troubleshooting, the best tool is the system log. Anacron logs its activity to syslog (typically /var/log/syslog or /var/log/messages). You can grep for 'anacron' to see when jobs were checked, delayed, executed, and whether they succeeded or failed. Also check the timestamp file modification time; 'ls -la /var/spool/anacron' shows when it was last updated.

anacron is not a complex tool, it has a simple configuration, clear behavior, and specific use cases. Mastering it ensures you can handle scheduling for all types of Linux systems, not just servers.

Memory Tip

Think 'Anacron = Anytime cron.' It catches up on missed cron jobs like an alligator snapping up whatever it missed, but it works on days, not minutes.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

XK0-005XK0-006(current version)

Related Glossary Terms

Frequently Asked Questions

Can anacron run a job at a specific time, like 3:00 PM?

No, anacron operates at a day granularity. It cannot schedule jobs at a specific hour or minute. You must use cron or systemd timers for exact-time scheduling.

What happens if I set the anacron period to 0 days?

Setting period to 0 means the job will be eligible to run every time anacron is invoked. This effectively makes it run on every boot, after the delay. It is not a typical use case and is not recommended.

Does anacron run jobs in parallel?

No, anacron runs jobs sequentially, one after another. If one job takes a long time, the next jobs will be delayed.

Where does anacron store its timestamp files?

Timestamps are stored in /var/spool/anacron. Each job identifier has a corresponding file containing the date of the last successful execution.

Can anacron be used on Windows?

No, anacron is a Unix/Linux tool. Windows has its own Task Scheduler which can handle similar functionality, including missed task execution.

How do I force an anacron job to run immediately?

You can delete or backdate the timestamp file in /var/spool/anacron for that job, then restart the anacron service or trigger anacron manually by running 'sudo anacron -f' (force run). Use with caution.

What is the difference between /etc/cron.daily and /etc/anacrontab?

On many systems, /etc/cron.daily is a directory of scripts that are run by anacron (via /etc/crontab). /etc/anacrontab is the main configuration file where you define custom anacron jobs directly.

Can anacron run jobs more than once a day?

The minimum period is 1 day, so anacron cannot run a job multiple times within the same day. If you need sub-daily scheduling, use cron.

Summary

Anacron is a simple yet essential Linux scheduling tool designed for computers that are not always turned on. It solves a real problem: cron jobs fail to execute when the system is off at the scheduled time. Anacron ensures that important periodic maintenance tasks, like log rotation, backups, and system updates, still happen, just later than originally planned. By tracking the last run date and comparing it to a configured period in days, anacron catches up on missed jobs after the next system boot, applying a configurable delay to allow the system to stabilize.

For IT certification exams, especially CompTIA Linux+ and LPIC-1, understanding anacron means knowing its configuration file location (/etc/anacrontab), the syntax (period delay job-id command), its behavior (sequential execution, timestamp updates only on success, no hourly scheduling), and its relationship with cron (anacron handles daily/weekly/monthly jobs on desktops; cron handles precise-time jobs on servers). Common exam traps include confusing the cron and anacron file formats, assuming anacron can schedule hourly tasks, and believing that anacron accumulates missed runs.

The key takeaway for exam success is: Anacron is not a replacement for cron but a complement. Use cron for exact-time tasks on always-on machines. Use anacron for periodic catch-up tasks on machines that come and go. With this understanding, you can confidently answer scheduling scenario questions and avoid the most common mistakes.