Re: backslash in crontab
From: Matthew Seaman (m.seaman_at_infracaninophile.co.uk)
Date: Sat, 31 May 2003 11:04:36 +0100 To: Antoine Jacoutot <firstname.lastname@example.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:
0 2 * * * myscript
% cat <<E_O_SCRIPT > myscript
command A && \
command B && \
-- 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
- application/pgp-signature attachment: stored