Re: backslash in crontab

From: Matthew Seaman (m.seaman_at_infracaninophile.co.uk)
Date: 05/31/03

  • Next message: Matthew Seaman: "Re: /stand/sysinstall with upgraded 5.1-BETA"
    Date: Sat, 31 May 2003 11:04:36 +0100
    To: Antoine Jacoutot <ajacoutot@lphp.org>
    
    
    

    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 message: Matthew Seaman: "Re: /stand/sysinstall with upgraded 5.1-BETA"

    Relevant Pages