DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Renaming .bad files

  1. #1
    Join Date
    Mar 2002
    Location
    Mesa, Arizona
    Posts
    1,204

    Renaming .bad files

    This is a (bash) script that renames my import bad file(s) if they exist with a date stamp.

    for file in /import/load/bad/*.bad
    do
    mv $file $file-`date "+%y%m%d%n"`
    done

    If there are no bad files, I get this error message:
    "No such file or directory"

    It triggers cron to send me an email that is not necessary. I don't want to know that there are no bad files.

    I've tried a couple things that haven't worked:

    Encase in if
    ----------------
    if [ -e /import/load/bad/*.bad ];
    then
    do ... done
    fi
    RESULT: line 1: [: /import/load/bad/verb1.bad: binary operator expected
    NOTE: I'm guessing I can't test with a wildcard.

    Get last file
    -------------
    CHECK=`ls -rt /import/load/bad/*.bad|tail -1`
    echo $CHECK
    RESULT: ls: /import/load/bad/*.bad: No such file or directory

  2. #2
    Join Date
    Jan 2001
    Posts
    3,134
    How does that script trigger a cronjob?


    Can you post the cronjob?
    I remember when this place was cool.

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    man find

    find /import/load/bad/ -name \*.bad -type f
    Jeff Hunter

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by Mr.Hanky
    How does that script trigger a cronjob?


    Can you post the cronjob?
    Look Windoz boy, when the job you are running sends output to stderr cron sends you the output of stderr in an email.
    Jeff Hunter

  5. #5
    Join Date
    Jan 2001
    Posts
    3,134
    Originally posted by marist89
    Look Windoz boy, when the job you are running sends output to stderr cron sends you the output of stderr in an email.

    HUH?

    I NEVER got an email from ANY Unix job I have run.

    Educate us all oh "Geniused" one.

    http://www.ucs.ed.ac.uk/usd/scisup/f...rection-1.html

    Says the default is the terminal.
    Last edited by Mr.Hanky; 06-15-2005 at 03:50 PM.
    I remember when this place was cool.

  6. #6
    Join Date
    Mar 2002
    Location
    Mesa, Arizona
    Posts
    1,204
    "find" is so sweet...

    /usr/bin/find /import/load/bad/ -name \*.bad -type f -exec mv {} {}-`date "+%y%m%d%n"` \;

    When there are no files, it doesn't return the error.

    Nice .. Thanks guys!

  7. #7
    Join Date
    Feb 2003
    Location
    Leeds, UK
    Posts
    367
    Errr, that link isn't talking about cron.

    From http://216.147.18.102/unixfaq/cron.shtml:
    "Any output your cron job produces, both stdout and stderr, will be sent to you by Unix email
    Last edited by hacketta1; 06-16-2005 at 07:23 AM.

  8. #8
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Originally posted by Mr.Hanky
    HUH?

    I NEVER got an email from ANY Unix job I have run.
    Hey genious, log into Unix and type mail, then press return!

  9. #9
    Join Date
    Nov 2004
    Location
    Mumbai, India
    Posts
    452
    This could also have worked
    for file in `ls -l /import/load/bad/*.bad 2>/dev/null`
    do
    echo $file
    done
    There are three kinds of lies: Lies, damned lies, and benchmarks...

    Unix is user friendly. It's just very particular about who it's friends are.

    Oracle DBA

  10. #10
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by Mr.Hanky

    I NEVER got an email from ANY Unix job I have run.
    Perhaps you never ran a cron job, eh?

    Educate us all oh "Geniused" one.

    http://www.ucs.ed.ac.uk/usd/scisup/f...rection-1.html

    Says the default is the terminal.
    From a cron my point-and-click friend, the default is mail.
    Jeff Hunter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width