Skip to content

Commit 7665ac8

Browse files
author
ryan nemeth
committed
anacron til
1 parent d4677c9 commit 7665ac8

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

content/til/2025-08-24-anacron.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: 'Anacron'
3+
date: '2025-08-24'
4+
author: Ryan
5+
layout: post
6+
categories:
7+
- Uncategorized
8+
---
9+
10+
Anacron is designed for tasks that need to run periodically (daily, weekly, monthly) on systems that are not continuously powered on. If a scheduled cron task is missed because the system is off, anacron will run the task once the system is available.
11+
12+
On many systems, anacron is pre-installed. If not, install it with:
13+
~~~
14+
$ sudo apt install anacron
15+
Anacron's configuration is in the /etc/anacrontab file, which includes helpful comments and examples. Here’s an excerpt:
16+
17+
$ sudo vim /etc/anacrontab
18+
# See anacron(8) and anacrontab(5) for details.
19+
# These entries replace cron's job entries.
20+
1 5 cron.daily run-parts --report /etc/cron.daily
21+
7 10 cron.weekly run-parts --report /etc/cron.weekly
22+
@monthly 15 cron.monthly run-parts --report /etc/cron.monthly
23+
~~~
24+
25+
The syntax in the anacrontab file consists of four fields:
26+
1) The period in days (e.g., 1 for daily, 7 for weekly).
27+
2) A delay (in minutes) after system startup.
28+
3) A unique job identifier.
29+
4) The command to execute.
30+
31+
For example, to run a job every three days with a 10-minute delay:
32+
~~~
33+
3 10 test_job /usr/bin/touch /root/anacron_created_this
34+
~~~
35+
36+
Other examples include:
37+
~~~
38+
7 10 test_job /usr/bin/touch /root/anacron_created_this
39+
@monthly 10 test_job /usr/bin/touch /root/anacron_created_this
40+
~~~
41+
42+
After editing, verify your anacrontab syntax with:
43+
~~~
44+
$ anacron -T
45+
anacron: /etc/anacrontab: Unknown named period on line 13, skipping
46+
~~~
47+
48+
If no errors are reported, your anacron entries are correctly formatted.
49+
50+
Consult the anacron man pages for more info.

0 commit comments

Comments
 (0)