Skip to content

Commit 55f4057

Browse files
author
Marcela Mašláňová
committed
Initial upload of anacron-2.3 which should be optimized for better
cooperation with cronie. However, cronie should be working with or without anacron, which should be configurable.
1 parent 57313e7 commit 55f4057

File tree

17 files changed

+2606
-0
lines changed

17 files changed

+2606
-0
lines changed

‎anacron/COPYING‎

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

‎anacron/ChangeLog‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Changes in Anacron 2.3
2+
----------------------
3+
* anacron can now read an arbitrary anacrontab file, use the -t option
4+
5+
6+
Changes in Anacron 2.1/2.2
7+
--------------------------
8+
* Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)> is now maintainer
9+
* if timestamp is from the future, re-run job
10+
* ansi cleanup / code cleaning
11+
12+
13+
Changes in Anacron 2.0.1
14+
------------------------
15+
* Minor cosmetic changes to log messages.
16+
* Jobs are now started with "/" as their working directory. This is
17+
more compatible with older Anacron versions, avoids annoying errors on
18+
some systems, and generally seems to make more sense.
19+
20+
21+
Summary of major changes in Anacron 2.0
22+
---------------------------------------
23+
* Complete rewrite in C. Should be backwards compatible with existing
24+
Anacron installations.
25+
* First release as a "generic" Linux package (was a Debian package).
26+
* No longer needs special lock-files. Locking is done on the timestamp
27+
files.
28+
* Sends log messages to syslogd. There's no log file now.
29+
* Output of jobs, if any, is mailed to the user.
30+
* Added command line options: -s -f -n -d -q -u -V -h. See the manpage.
31+
* Specific jobs can now be selected on the command line.
32+
* Added SIGUSR1 handling, to cleanly stop execution.
33+
* Jobs will now be started with their current directory set to the home
34+
of the user running Anacron (usually root).

‎anacron/Makefile‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Anacron - run commands periodically
2+
# Copyright (C) 1998 Itai Tzur <itzur@actcom.co.il>
3+
#
4+
# This program is free software; you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation; either version 2 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
#
18+
# The GNU General Public License can also be found in the file
19+
# `COPYING' that comes with the Anacron source distribution.
20+
21+
22+
PREFIX =
23+
BINDIR = $(PREFIX)/usr/sbin
24+
MANDIR = $(PREFIX)/usr/man
25+
CFLAGS = -Wall -pedantic -O2
26+
#CFLAGS = -Wall -O2 -g -DDEBUG
27+
28+
# If you change these, please update the man-pages too
29+
# Only absolute paths here, please
30+
SPOOLDIR = /var/spool/anacron
31+
ANACRONTAB = /etc/anacrontab
32+
33+
RELEASE = 2.3
34+
package_name = anacron-$(RELEASE)
35+
distfiles = ChangeLog COPYING README TODO anacron.8 anacrontab.5 Makefile *.h *.c
36+
37+
SHELL = /bin/sh
38+
INSTALL = install
39+
INSTALL_PROGRAM = $(INSTALL)
40+
INSTALL_DATA = $(INSTALL)
41+
INSTALL_DIR = $(INSTALL) -d
42+
GZIP = gzip -9 -f
43+
ALL_CPPFLAGS = -DSPOOLDIR=\"$(SPOOLDIR)\" -DRELEASE=\"$(RELEASE)\" \
44+
-DANACRONTAB=\"$(ANACRONTAB)\" $(CPPFLAGS)
45+
46+
csources := $(wildcard *.c)
47+
objects = $(csources:.c=.o)
48+
49+
.PHONY: all
50+
all: anacron
51+
52+
# This makefile generates header file dependencies auto-magically
53+
%.d: %.c
54+
$(SHELL) -ec "$(CC) -MM $(ALL_CPPFLAGS) $< \
55+
| sed '1s/^\(.*\)\.o[ :]*/\1.d &/1' > $@"
56+
57+
include $(csources:.c=.d)
58+
59+
anacron: $(objects)
60+
$(CC) $(LDFLAGS) $^ $(LOADLIBES) -o $@
61+
62+
%.o : %.c
63+
$(CC) -c $(ALL_CPPFLAGS) $(CFLAGS) $< -o $@
64+
65+
.PHONY: installdirs
66+
installdirs:
67+
$(INSTALL_DIR) $(BINDIR) $(PREFIX)$(SPOOLDIR) \
68+
$(MANDIR)/man5 $(MANDIR)/man8
69+
70+
.PHONY: install
71+
install: installdirs
72+
$(INSTALL_PROGRAM) anacron $(BINDIR)/anacron
73+
$(INSTALL_DATA) anacrontab.5 $(MANDIR)/man5/anacrontab.5
74+
$(INSTALL_DATA) anacron.8 $(MANDIR)/man8/anacron.8
75+
76+
.PHONY: clean
77+
clean:
78+
rm -f *.o *.d anacron
79+
80+
distclean: clean
81+
rm -f *~
82+
83+
.PHONY: dist
84+
dist: $(package_name).tar.gz
85+
86+
$(package_name).tar.gz: $(distfiles)
87+
mkdir $(package_name)
88+
ln $(distfiles) $(package_name)
89+
chmod 0644 $(package_name)/*
90+
chmod 0755 $(package_name)
91+
tar cf $(package_name).tar $(package_name)
92+
$(GZIP) $(package_name).tar
93+
rm -r $(package_name)
94+
95+
release: distclean $(package_name).tar.gz

‎anacron/README‎

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
2+
What is Anacron ?
3+
-----------------
4+
5+
Anacron is a periodic command scheduler. It executes commands at
6+
intervals specified in days. Unlike cron, it does not assume that the
7+
system is running continuously. It can therefore be used to control
8+
the execution of daily, weekly and monthly jobs (or anything with a
9+
period of n days), on systems that don't run 24 hours a day. When
10+
installed and configured properly, Anacron will make sure that the
11+
commands are run at the specified intervals as closely as
12+
machine-uptime permits.
13+
14+
Every time Anacron is run, it reads a configuration file that
15+
specifies the jobs Anacron controls, and their periods in days. If a
16+
job wasn't executed in the last n days, where n is the period of that
17+
job, Anacron executes it. Anacron then records the date in a special
18+
timestamp file that it keeps for each job, so it can know when to run
19+
it again. When all the executed commands terminate, Anacron exits.
20+
21+
It is recommended to run Anacron from the system boot-scripts.
22+
This way the jobs "whose time has come" will be run shortly after the
23+
machine boots. A delay can be specified for each job so that the
24+
machine isn't overloaded at boot time.
25+
26+
In addition to running Anacron from the boot-scripts, it is also
27+
recommended to schedule it as a daily cron-job (usually at an early
28+
morning hour), so that if the machine is kept running for a night,
29+
jobs for the next day will still be executed.
30+
31+
32+
Why this may be useful ?
33+
------------------------
34+
35+
Most Unix-like systems have daily, weekly and monthly scripts that
36+
take care of various "housekeeping chores" such as log-rotation,
37+
updating the "locate" and "man" databases, etc. Daily scripts are
38+
usually scheduled as cron-jobs to execute around 1-7 AM. Weekly
39+
scripts are scheduled to run on Sundays. On machines that are turned
40+
off for the night or for the weekend, these scripts rarely get run.
41+
42+
Anacron solves this problem. These jobs can simply be scheduled as
43+
Anacron-jobs with periods of 1, 7 and 30 days.
44+
45+
46+
What Anacron is not ?
47+
---------------------
48+
49+
Anacron is not an attempt to make cron redundant. It cannot
50+
currently be used to schedule commands at intervals smaller than days.
51+
It also does not guarantee that the commands will be executed at any
52+
specific day or hour.
53+
54+
It isn't a full-time daemon. It has to be executed from boot
55+
scripts, from cron-jobs, or explicitly.
56+
57+
58+
For more details, see the anacron(8) manpage.
59+
60+
61+
Requirements
62+
------------
63+
64+
- A Linux system. (maybe other *NIX systems)
65+
- A functioning syslog daemon.
66+
- A functioning /usr/lib/sendmail command. (all MTAs should have
67+
that).
68+
69+
70+
Compilation and Installation
71+
----------------------------
72+
73+
- Untar the source package.
74+
75+
- Check the Makefile. Edit as required.
76+
77+
- Check the top of "global.h". You may want to change the syslog
78+
facility and priorities, and the path to your MTA's sendmail
79+
compatible command (/usr/lib/sendmail).
80+
81+
- cd to the directory.
82+
83+
- Type "make".
84+
You can safely ignore warnings of the form: "*.d: No such file or
85+
directory"
86+
87+
- Become root. Type "make install".
88+
89+
90+
Setup
91+
-----
92+
93+
1. Locate your system's daily, weekly and monthly cron-jobs.
94+
See your cron documentation for more details.
95+
96+
2. Decide which of these jobs should be controlled by Anacron.
97+
Remember that Anacron does not guarantee execution at any specific
98+
day of the month, day of the week, or time of day. Jobs for which
99+
the timing is critical should probably not be controlled by
100+
Anacron.
101+
102+
3. Comment these jobs out of their crontab files. (You may have to
103+
use the "crontab" command for this. See the cron documentation.)
104+
105+
4. Put them in /etc/anacrontab. Note that the format is not the same
106+
as the crontab entries. See the anacrontab(5) manpage. Here's an
107+
example from a typical Debian system:
108+
109+
-----Cut
110+
# /etc/anacrontab example
111+
SHELL=/bin/sh
112+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
113+
# format: period delay job-identifier command
114+
1 5 cron.daily run-parts /etc/cron.daily
115+
7 10 cron.weekly run-parts /etc/cron.weekly
116+
30 15 cron.monthly run-parts /etc/cron.monthly
117+
-----Cut
118+
119+
5. Put the command "anacron -s" somewhere in your boot-scripts.
120+
Make sure that syslogd is started before this command.
121+
122+
6. Schedule the command "anacron -s" as a daily cron-job (preferably
123+
at some early morning hour). This will make sure that jobs are run
124+
when the systems is left running for a night.
125+
126+
That's it.
127+
128+
It is a good idea to check what your daily, weekly and monthly scripts
129+
actually do, and disable any parts that may be irrelevant for your
130+
system.
131+
132+
133+
Credits
134+
-------
135+
136+
Anacron was originally conceived and implemented by Christian Schwarz
137+
<schwarz@monet.m.isar.de>.
138+
139+
The current implementation is a complete rewrite by Itai Tzur
140+
<itzur@actcom.co.il>.
141+
142+
Current code base maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.

‎anacron/TODO‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
anacron runs jobs twice in a 31 day month
2+
add hostname to emails sent to admin
3+
allow user anacrontabs
4+
make manpages match #defines automagically --> sed fu
5+
full ANSI / POSIX compliance
6+
code cleaning

0 commit comments

Comments
 (0)