Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 May 2003 11:04:36 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Antoine Jacoutot <ajacoutot@lphp.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: backslash in crontab
Message-ID:  <20030531100436.GA75487@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <200305311049.38120.ajacoutot@lphp.org>
References:  <200305311049.38120.ajacoutot@lphp.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, May 31, 2003 at 10:49:34AM +0200, Antoine Jacoutot wrote:
> Hi !
>=20
> How can I have one big line in my crontab splitted in multiple lines ?
> I tried the following:
>=20
> 0 2 * * * command A && \
> command B && \
> command C
>=20
> But I get the following error message:
>=20
> /tmp/crontab.48pe18LXs2: 10 lines, 1344 characters.
> crontab: installing new crontab
> "/tmp/crontab.48pe18LXs2":9: bad hour
> crontab: errors in crontab file, can't install
> Do you want to retry the same edit?
>=20
> Note that if my crontab is written as:
>=20
> 0 2 * * * command A && command B && command C
> ... then it works with no problem.

Yes -- the entry in the crontab file has to be all on one line, as
you've discovered.  If you absolutely have to reformat things, then
generally the way to go is to create a shell script containing your
complex command and run that out of cron instead:

crontab entry:

    0 2 * * * myscript

    % cat <<E_O_SCRIPT > myscript
    #!/bin/sh

    command A && \
        command B && \
        command C
    E_O_SCRIPT

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--82I3+IH0IqGh5yIs
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE+2H40dtESqEQa7a0RAgxRAJ9FgNhuH/qDAZ0UjeT7XEM+Ii/oVgCeL78o
UYbCd16r/sriE9g1qXsvYZI=
=5WFh
-----END PGP SIGNATURE-----

--82I3+IH0IqGh5yIs--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030531100436.GA75487>