problem with crontab - Help

This is a discussion on problem with crontab - Help ; Hello all; If this is the wrong newsgroup to post this, please let me know and where it should be posted. I want to use cron to backup my log files on my web site and insert the date into ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: problem with crontab

  1. problem with crontab

    Hello all;

    If this is the wrong newsgroup to post this, please let me know and where it
    should be posted.

    I want to use cron to backup my log files on my web site and insert the date
    into the file name. I tested what I wanted to do with the following command
    from the shell prompt:

    cp -v logs/access.log xxx/access_`date '+%B_%d_%Y'`.log

    then did an "ls -la xxx" command. It shows:

    -rw-r--r-- 1 ccs sncweb 21794 Oct 23 00:58
    access_October_23_2004.log

    so the it worked as desired. Then, I put the line into my crontab. When it
    runs via cron, I get:

    /bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
    /bin/sh: -c: line 2: syntax error: unexpected end of file

    I did some searching on google and came across an article at
    http://forums.devshed.com/showthread...581#post825581 that mentions
    the % characters need to be escaped, so I modified the command to be:

    cp -v logs/access.log xxx/access_`date '+\%B_\%d_\%Y'`.log

    This now works in crontab, but the filename contains \ characters, as shown
    below:

    -rw-r--r-- 1 ccs sncweb 21794 Oct 23 00:58
    access_\October_\23_\2004.log

    Can someone enlighten me on what I am overlooking and how to get the \ chars
    out of the filename?

    TIA.

    Charles...


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.779 / Virus Database: 526 - Release Date: 10/19/04



  2. Re: problem with crontab

    On Sat, 23 Oct 2004 01:31:03 GMT, Charles Crume wrote:
    | Hello all;
    |
    | If this is the wrong newsgroup to post this, please let me know and where it
    | should be posted.
    |
    | I want to use cron to backup my log files on my web site and insert the date
    | into the file name. I tested what I wanted to do with the following command
    | from the shell prompt:
    |
    | cp -v logs/access.log xxx/access_`date '+%B_%d_%Y'`.log
    |
    | then did an "ls -la xxx" command. It shows:
    |
    | -rw-r--r-- 1 ccs sncweb 21794 Oct 23 00:58
    | access_October_23_2004.log
    |
    | so the it worked as desired. Then, I put the line into my crontab. When it
    | runs via cron, I get:
    |
    | /bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
    | /bin/sh: -c: line 2: syntax error: unexpected end of file
    |
    | I did some searching on google and came across an article at
    | http://forums.devshed.com/showthread...581#post825581 that mentions
    | the % characters need to be escaped, so I modified the command to be:
    |
    | cp -v logs/access.log xxx/access_`date '+\%B_\%d_\%Y'`.log


    Put the original command line into a file, make the file executable, and
    call that file from cron. Much easier than messing abount with quoting levels.


    --
    Reverend Paul Colquhoun, ULC. http://andor.dropbear.id.au/~paulcol
    Asking for technical help in newsgroups? Read this first:
    http://catb.org/~esr/faqs/smart-questions.html#intro

  3. Re: problem with crontab


    "Paul Colquhoun" wrote in message
    news:slrncnka05.rnq.postmaster@andor.dropbear.id.a u...
    > On Sat, 23 Oct 2004 01:31:03 GMT, Charles Crume

    wrote:

    [snip]

    > Put the original command line into a file, make the file executable, and
    > call that file from cron. Much easier than messing abount with quoting

    levels.

    Hi Paul;

    Thanks for the reply.

    I agree with your suggestion, and know how to do it that way. However, as I
    am trying to learn Unix/Linux, I am interested in understanding why the \
    chars are inserted into the file name and how to solve the issue directly.
    Hope that you, or perhaps someone else, can enlighten me.

    If not, I will, of course, do as you suggest.

    Thanks again for your assistance.

    Charles...


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.779 / Virus Database: 526 - Release Date: 10/19/04



  4. Re: problem with crontab

    "Charles Crume" writes:
    >
    > This now works in crontab, but the filename contains \ characters, as shown
    > below:
    >
    > -rw-r--r-- 1 ccs sncweb 21794 Oct 23 00:58
    > access_\October_\23_\2004.log
    >
    > Can someone enlighten me on what I am overlooking and how to get the \ chars
    > out of the filename?


    It's a cron bug in Paul Vixie's original source. I think most
    distributions have patched it, but if your distribution is long in the
    tooth or you compiled "cron" on your own, you'll need to get your
    hands on a patch.

    --
    Kevin

  5. Re: problem with crontab

    Hello Kevin;

    Thanks for the "heads up"!!! The outpur from "crontab -l' is:

    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (/tmp/crontab.12674 installed on Sat Oct 23 19:18:34 2004)
    # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)

    "1994" is a *little* long in the tooth, no?? ;-)

    Guess I better contact my ISP (FWIW they do a good job if anyone is looking
    for hosting services).

    Thanks again.

    Charles...



    "Kevin Buhr" wrote in message
    news:873c02cm1i.fsf@saurus.asaurus.invalid...
    > "Charles Crume" writes:
    > >
    > > This now works in crontab, but the filename contains \ characters, as

    shown
    > > below:
    > >
    > > -rw-r--r-- 1 ccs sncweb 21794 Oct 23 00:58
    > > access_\October_\23_\2004.log
    > >
    > > Can someone enlighten me on what I am overlooking and how to get the \

    chars
    > > out of the filename?

    >
    > It's a cron bug in Paul Vixie's original source. I think most
    > distributions have patched it, but if your distribution is long in the
    > tooth or you compiled "cron" on your own, you'll need to get your
    > hands on a patch.
    >
    > --
    > Kevin



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.782 / Virus Database: 528 - Release Date: 10/22/04



+ Reply to Thread