backslash in crontab

Matthew Seaman m.seaman at infracaninophile.co.uk
Sat May 31 03:04:48 PDT 2003


On Sat, May 31, 2003 at 10:49:34AM +0200, Antoine Jacoutot wrote:
> Hi !
> 
> How can I have one big line in my crontab splitted in multiple lines ?
> I tried the following:
> 
> 0 2 * * * command A && \
> command B && \
> command C
> 
> But I get the following error message:
> 
> /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?
> 
> Note that if my crontab is written as:
> 
> 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

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030531/a6e6ace4/attachment.bin


More information about the freebsd-questions mailing list