Discussion:
Problems with anacron.
(too old to reply)
Jean-David Beyer
2013-03-29 12:06:27 UTC
Permalink
I am running Red Hat Enterprise Linux Server release 6.4 (Santiago).
In the past I was running RHEL 5, I filled in file /etc/crontab with
what I wanted to run and when I wanted to run it. For example, I had the
following entries in it

M H D m d user program arguments
01 * * * * root run-parts /etc/cron.hourly
04 1 * * 1-6 root run-parts /etc/cron.daily
04 3 * * 0 root run-parts /etc/cron.weekly
19 4 1 * * root run-parts /etc/cron.monthly

The last line would cause things to run the first day of each month at
04:19 in the morning.

With RHEL6, they do things differently and files in /var/spool/anacron
handle _when_ things are run.

For example, cron.monthly contains

20130329

It last ran March 1, and it tried to run today.
It runs a backup script to do a full backup to tape, but there was no
tape in the drive, so it failed.

I expected it to run April 1.

The cron.daily runs things every day, and the cron.weekly runs things
every week on Monday as I wish

How should I make /var/spool/anacron/cron.monthly run things on the
first of the month? Or, if that is the wrong question, how should I have
the cron system run my backup job on the first of the month? I suppose
if I put the right line in /etc/crontab it would work, but I am not
sure. Right now /etc/crontab is like this:

# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

I.e, it is essentially empty. I do not want to merely get it to work; I
want to do it using the current philosophy, but I do not understand the
current philosophy.
Scott Hemphill
2013-04-02 18:23:49 UTC
Permalink
Post by Jean-David Beyer
I am running Red Hat Enterprise Linux Server release 6.4 (Santiago).
In the past I was running RHEL 5, I filled in file /etc/crontab with
what I wanted to run and when I wanted to run it. For example, I had the
following entries in it
M H D m d user program arguments
01 * * * * root run-parts /etc/cron.hourly
04 1 * * 1-6 root run-parts /etc/cron.daily
04 3 * * 0 root run-parts /etc/cron.weekly
19 4 1 * * root run-parts /etc/cron.monthly
The last line would cause things to run the first day of each month at
04:19 in the morning.
With RHEL6, they do things differently and files in /var/spool/anacron
handle _when_ things are run.
For example, cron.monthly contains
20130329
It last ran March 1, and it tried to run today.
It runs a backup script to do a full backup to tape, but there was no
tape in the drive, so it failed.
I expected it to run April 1.
The cron.daily runs things every day, and the cron.weekly runs things
every week on Monday as I wish
How should I make /var/spool/anacron/cron.monthly run things on the
first of the month? Or, if that is the wrong question, how should I have
the cron system run my backup job on the first of the month? I suppose
if I put the right line in /etc/crontab it would work, but I am not
# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
I.e, it is essentially empty. I do not want to merely get it to work; I
want to do it using the current philosophy, but I do not understand the
current philosophy.
Anacron and cron are two different things and you have both of them.
Anacron is designed to make sure that scheduled tasks get run even if
your system is down. I agree that its monthly logic is a little
strange, but I haven't been sufficiently motivate to figure it out.
None of its options does what you want.

What you want to use for this task is cron, not anacron. If your system
is down on the 1st, your task will not run. You can use /etc/crontab
for this purpose, or you can edit root's private crontab using "crontab -e".

Scott
--
Scott Hemphill ***@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
Jean-David Beyer
2013-04-02 20:30:10 UTC
Permalink
Post by Scott Hemphill
Post by Jean-David Beyer
I am running Red Hat Enterprise Linux Server release 6.4 (Santiago).
In the past I was running RHEL 5, I filled in file /etc/crontab with
what I wanted to run and when I wanted to run it. For example, I had the
following entries in it
M H D m d user program arguments
01 * * * * root run-parts /etc/cron.hourly
04 1 * * 1-6 root run-parts /etc/cron.daily
04 3 * * 0 root run-parts /etc/cron.weekly
19 4 1 * * root run-parts /etc/cron.monthly
The last line would cause things to run the first day of each month at
04:19 in the morning.
With RHEL6, they do things differently and files in /var/spool/anacron
handle _when_ things are run.
For example, cron.monthly contains
20130329
It last ran March 1, and it tried to run today.
It runs a backup script to do a full backup to tape, but there was no
tape in the drive, so it failed.
I expected it to run April 1.
The cron.daily runs things every day, and the cron.weekly runs things
every week on Monday as I wish
How should I make /var/spool/anacron/cron.monthly run things on the
first of the month? Or, if that is the wrong question, how should I have
the cron system run my backup job on the first of the month? I suppose
if I put the right line in /etc/crontab it would work, but I am not
# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
I.e, it is essentially empty. I do not want to merely get it to work; I
want to do it using the current philosophy, but I do not understand the
current philosophy.
Anacron and cron are two different things and you have both of them.
Anacron is designed to make sure that scheduled tasks get run even if
your system is down.
I am quibbling here. Of course anacron cannot run anything while the
machine is down. ;-) I am sure you mean that it will run the missed
tasks as soon as practical after the system comes back up.
Post by Scott Hemphill
I agree that its monthly logic is a little
strange, but I haven't been sufficiently motivate to figure it out.
None of its options does what you want.
What you want to use for this task is cron, not anacron. If your system
is down on the 1st, your task will not run. You can use /etc/crontab
for this purpose, or you can edit root's private crontab using "crontab -e".
Since I normally leave the system up 24/7, unless I take it down for
rebooting
a new kernel, or to run Windows (at income tax time), I suppose that I
could just make some entries in /etc/crontab as I used to do and run
that way. Or, since cron.daily and cron.weekly seem to work OK with
anacron, leave them and just put the monthly one in /etc/crontab.

I was just worried that if I put stuff into crontab, I would mess things up.
Scott Hemphill
2013-04-02 21:42:24 UTC
Permalink
[snip]
Post by Jean-David Beyer
Post by Scott Hemphill
Anacron and cron are two different things and you have both of them.
Anacron is designed to make sure that scheduled tasks get run even if
your system is down.
I am quibbling here. Of course anacron cannot run anything while the
machine is down. ;-) I am sure you mean that it will run the missed
tasks as soon as practical after the system comes back up.
I was really hoping that anacron had that functionality. I could save
electricity. :-)
Post by Jean-David Beyer
Post by Scott Hemphill
I agree that its monthly logic is a little
strange, but I haven't been sufficiently motivate to figure it out.
None of its options does what you want.
What you want to use for this task is cron, not anacron. If your system
is down on the 1st, your task will not run. You can use /etc/crontab
for this purpose, or you can edit root's private crontab using "crontab -e".
Since I normally leave the system up 24/7, unless I take it down for
rebooting
a new kernel, or to run Windows (at income tax time), I suppose that I
could just make some entries in /etc/crontab as I used to do and run
that way. Or, since cron.daily and cron.weekly seem to work OK with
anacron, leave them and just put the monthly one in /etc/crontab.
I was just worried that if I put stuff into crontab, I would mess things up.
By all means leave the system stuff that's handled by cron.daily and
cron.weekly there. You could also leave what was orginally in
cron.monthly, if anything. You won't mess anything up by using
/etc/crontab.

Scott
--
Scott Hemphill ***@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
Jean-David Beyer
2013-04-03 01:19:04 UTC
Permalink
Post by Scott Hemphill
[snip]
Post by Jean-David Beyer
Post by Scott Hemphill
Anacron and cron are two different things and you have both of them.
Anacron is designed to make sure that scheduled tasks get run even if
your system is down.
I am quibbling here. Of course anacron cannot run anything while the
machine is down. ;-) I am sure you mean that it will run the missed
tasks as soon as practical after the system comes back up.
I was really hoping that anacron had that functionality. I could save
electricity. :-)
Post by Jean-David Beyer
Post by Scott Hemphill
I agree that its monthly logic is a little
strange, but I haven't been sufficiently motivate to figure it out.
None of its options does what you want.
What you want to use for this task is cron, not anacron. If your system
is down on the 1st, your task will not run. You can use /etc/crontab
for this purpose, or you can edit root's private crontab using "crontab -e".
Since I normally leave the system up 24/7, unless I take it down for
rebooting
a new kernel, or to run Windows (at income tax time), I suppose that I
could just make some entries in /etc/crontab as I used to do and run
that way. Or, since cron.daily and cron.weekly seem to work OK with
anacron, leave them and just put the monthly one in /etc/crontab.
I was just worried that if I put stuff into crontab, I would mess things up.
By all means leave the system stuff that's handled by cron.daily and
cron.weekly there. You could also leave what was orginally in
cron.monthly, if anything.
There is one thing in there, and I left it there. I disremember what it is.
Post by Scott Hemphill
You won't mess anything up by using
/etc/crontab.
Scott
I was in doubt what would happen if I scheduled something at the same
time with cron and anacron, so the cron job is about 8 hours later.
Since the weekly anacron job uses the tape drive for backups, and the
cron job also uses the tape drive for backups (weekly and monthly), I
want one to run at night when I am asleep so it does not bother me, and
the other to run in the daytime, so I can put the new tape in before
cron runs it. This issue matters only when the month starts on the same
day as the week does. Weekly is always on Monday, and Monthly is always
the first day of the month.

As one of my T-shirts says, "POBODY'S NERFECT."

Loading...