[vox-tech] cron - not at a different time

Samuel N. Merritt vox-tech@lists.lugod.org
Wed, 3 Mar 2004 11:56:47 -0800


--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Mar 03, 2004 at 11:40:24AM -0800, Peter Jay Salzman wrote:
> On Wed 03 Mar 04, 11:28 AM, Jeff Newmiller <jdnewmil@dcn.davis.ca.us> sai=
d:
> > On Wed, 3 Mar 2004, Ken Herron wrote:
> >=20
> > > --On Wednesday, March 03, 2004 10:11:10 -0800 Peter Jay Salzman=20
> > > <p@dirac.org> wrote:
> > >=20
> > > >> > 25 4 * * * root test -e /usr/sbin/anacron || run-parts --report
> > > >> /etc/cron.daily
> > > >>
> > > >> That line will only launch "run-parts" if /usr/sbin/anacron doesn't
> > > >> exist. Does /usr/sbin/anacron exist?
> > > >
> > > > ken,
> > > >
> > > > yeah, it does exist.   daily definitely runs.  it just runs at a ti=
me i
> > > > wasn't expecting.
> > >=20
> > > My point was that if /usr/sbin/anacron exists, then the crontab line=
=20
> > > above will not run cron.daily. You say that /usr/sbin/anacron exists,=
 so=20
> > > cron.daily is not being launched as a result of the above crontab lin=
e.=20
> > > That means something else is running it. Something like anacron, for=
=20
> > > example.
> >=20
> > This list is great.  This explains a longstanding puzzle (to me) of how
> > (and to some extent why) both cron and anacron are installed on my debi=
an
> > box.
> >=20
> > Now that I see how it works, I am not too impressed with this kludge,
> > though... this is a deceptively obtuse configuration duplication between
> > these two packages.
>=20
> ok, maybe i'm slow, but i don't understand why that line will only
> launch if /usr/sbin/anacron doesn't exist.

The shell uses short-circuit evaluation on conditionals. When it sees=20
A || B
it first evaluates A. Then if A is true, the value of the whole
conditional has to be true, so B never even gets evaluated.=20

So, if "test -e /usr/sbin/anacron" is true because anacron is installed,
then the shell doesn't bother with "run-parts --report /etc/cron.daily"
because it has already figured out the value of the conditional.

On the other hand, if "test -e /usr/sbin/anacron" is false, then the
shell is looking at (false || "run-parts --report /etc/cron.daily"),
which evaluates to whatever the right-hand side evaluates to.=20
=20
> /etc/init.d/cron gets run upon startup.  the only test i see is:
>=20
>    test -f /usr/sbin/cron || exit 0
>=20
> it doesn't look look for /usr/sbin/anacron.  what am i missing?
>=20
> pete
>=20
> --=20
> Make everything as simple as possible, but no simpler.  -- Albert Einstein
> GPG Instructions: http://www.dirac.org/linux/gpg
> GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D

--=20
Samuel Merritt
OpenPGP key is at http://meat.andcheese.org/~spam/spam_at_andcheese_dot_org=
.asc
Information about PGP can be found at http://www.mindspring.com/~aegreene/p=
gp/

--5mCyUwZo2JvN/JJP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFARjh/W3tuPJ1t7wURAljzAJ9xSA2phCO+fL+JfTLaU0nanI1tUgCeKaaG
zJeUs993GamnzjOaKE4eTt4=
=P3QI
-----END PGP SIGNATURE-----

--5mCyUwZo2JvN/JJP--