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

    • Re: Running DBI, ODBC in the crontab
      ... Run the following lines in both the command line and crontab: ... Any of the paths that are missing in cron ... This communication is issued by UBS AG or an affiliate by the ...
      (perl.dbi.users)
    • Re: GPG in crontab causes blank messages
      ... When I run my crontab command manually in terminal, ... But since the output of the script contains a big list of files, ... If I remove the GPG portion of the command, ...
      (comp.sys.mac.apps)
    • crontab command and permissions problem
      ... I'm having a problem trying to execute the "crontab" command from a perl script. ... I've tried to create the cron file, somewhere else, or to give it 777 permissions, but i always get the same error message. ... I've even tried to log a "whoami" command before it executes "crontab", and it says it's root, but then it says it is not allowed to execute the command. ...
      (Debian-User)
    • Re: Suppress email output of crontab job
      ... to the end of the crontab file. ... If you are not using the "crontab -e" command to edit the cron table, ... Use a real news client if you want me to see your posts. ...
      (comp.sys.mac.system)
    • Re: crontab issue
      ... your environment ... ... Simon is absolutely right about the script ... ... crontab file ugly, just because you can? ... solved by making the command a separate script. ...
      (AIX-L)