Results 1 to 5 of 5

Thread: small error in shellscripting

  1. #1
    Senior Member
    Join Date
    Apr 2011
    Posts
    113
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Rep Power
    4

    Default small error in shellscripting

    small error in shellscripting
    Last edited by aish; 13th October 2011 at 07:13 PM.

  2. #2
    Member Shell_Life's Avatar
    Join Date
    May 2011
    Location
    Bahia, Brazil
    Posts
    99
    Thanks
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    4

    Default

    What is the error?

  3. #3
    Senior Member
    Join Date
    Apr 2011
    Posts
    113
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Rep Power
    4

    Default small error in shellscripting -archival part

    Hi All,

    I have run the below script but getting one small error. please help me to solve this.

    ERROR:

    Code:
    tar: Error exit delayed from previous errors
    Code:
    #! /bin/bash
    CEP=/home/user01/exercise/CEP
    ARCH=/home/user01/exercise/archive
    LOG=/home/user01/exercise/logs
    #################### initialization
    # Archival date
    if [ `date +%a` = "Mon" ]; then
            let arc_date=`date +%Y%m%d --date='3 days ago'` # friday
    else
            let arc_date=`date +%Y%m%d --date='yesterday'`
    fi
    #################### archive previous files
    mkdir -p $ARCH/$arc_date
    if [ "$?" -eq "0" ]; then
            tar -Pczf $ARCH/${arc_date}/${arc_date}.tgz $LOG/*.log $CEP/*.log.* $CEP/Adapter/*.csv $CEP/*.csv
    rm -rf $LOG/*.log
    rm -rf $CEP/*.csv
    rm -rf $CEP/*.log.*
    rm -rf $CEP/Adapter/*.csv
    fi
    Thanks

  4. #4
    Senior Member
    Join Date
    Apr 2011
    Posts
    113
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Rep Power
    4

    Default

    Actually got below errors but other errors are due to non avaibilty of files
    but my question is why their is tar: Error exit delayed from previous errors
    ?

    Code:
    tar: /home/user01/exercise/logs/*.log: Cannot stat: No such file or directory
    tar: /home/user01/exercise/CEP/*.log.*: Cannot stat: No such file or directory
    tar: /home/user01/exercise/CEP/Adapter/*.csv: Cannot stat: No such file or directory
    tar: /home/user01/exercise/CEP/*.csv: Cannot stat: No such file or directory
    tar: Error exit delayed from previous errors

  5. #5
    Member Shell_Life's Avatar
    Join Date
    May 2011
    Location
    Bahia, Brazil
    Posts
    99
    Thanks
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    4

    Default

    Try to make sure there are files in the 'tar' parameters.

    Several ways you can do it, one of them is:
    Code:
     
    mTarFiles=''
     
    for mFName in $LOG/*.log; do
      if [[ -f ${mFName} ]]; then
        mTarFiles=${mTarFiles}' '${mFName}
      fi
    done
     
    for mFName in $CEP/*.log.*; do
      if [[ -f ${mFName} ]]; then
        mTarFiles=${mTarFiles}' '${mFName}
      fi
    done
     
    for mFName in $CEP/Adapter/*.csv; do
      if [[ -f ${mFName} ]]; then
        mTarFiles=${mTarFiles}' '${mFName}
      fi
    done
     
    for mFName in $CEP/*.csv; do
      if [[ -f ${mFName} ]]; then
        mTarFiles=${mTarFiles}' '${mFName}
      fi
    done
    ...
    if [[ "${mTarFiles}" != "" ]]; then
      tar -Pczf $ARCH/${arc_date}/${arc_date}.tgz ${mTarFiles}
    fi
    ...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Solved] Small error in unix shell script that is used for backing up files
    By aish in forum Shell scripting
    Replies: 4
    Last Post: 24th June 2011, 04:44 PM
  2. how to become a small public internet DNS supllier?
    By IsraelQuality in forum Domain Name Server
    Replies: 4
    Last Post: 9th November 2010, 03:28 PM
  3. Small Issue : please help resolvinig it
    By ermunishanand in forum Shell scripting
    Replies: 1
    Last Post: 11th October 2008, 01:54 AM
  4. Change /tmp path on KDE as it is too small for KDE
    By marccarter0 in forum Ubuntu / Debian
    Replies: 2
    Last Post: 26th May 2008, 09:34 PM
  5. Small handy one liners
    By digen in forum Getting started tutorials
    Replies: 0
    Last Post: 7th February 2007, 03:40 PM

Posting Permissions

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