Find the answer to your Linux question:
Results 1 to 4 of 4
hi folks. first of all, sorry about my poor english, i'm from brasil. i have some really important data to send from one server to another, so i have done ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11

    du giving different values

    hi folks.

    first of all, sorry about my poor english, i'm from brasil.

    i have some really important data to send from one server to another, so i have done a little bash script that send the data through scp from 20h until 8h am.

    my issue is that this data is really really important, and i can't afford to lose anything, so i have done a little check in the and of each directory transfer to check if the directory sizes are the same, so i can safely remove the data from the source server. i want to use bytes as metric for checking (in this case Kbytes is just too big to be a reliable metric).

    REMOTE_FILE=`ssh root@<ip-address> 'du -sb /var/data/*' | grep $1 | awk {'print $1'}`
    LOCAL_FILE=`du -sb /var/data/$1 | awk {'print $1'}`
    if [ $REMOTE_FILE == $LOCAL_FILE ]
    then
    rm -rf /var/data/$1
    else
    echo some error sending file $1. i'll try again later. >>/var/log/send.log
    sleep 300
    fi

    but even when the directory is correctly transfered, the du command return different values when executed in the local and remote machine. so the directory is never deleted and is re-sended over and over again.

    can anyone help me out with this one?

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    try using this as first line:

    REMOTE_FILE=`ssh root@<ip-address> du -sb /var/data/$1 | awk '{print $1}'`

    you may need it like this

    REMOTE_FILE=`ssh root@<ip-address> du -sb /var/data/ `$1` | awk '{print $1}'`

    to expose the shell variable
    the sun is new every day (heraclitus)

  3. #3
    Just Joined! sathiya's Avatar
    Join Date
    Feb 2008
    Location
    Bangalore, India
    Posts
    97
    md5sum is the right tool you need to use..

    the method you are following right now wont help you much, use md5sum.

  4. #4
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11
    tks sathiya. i hadn't ever consider user a hash check (something much more reliable). i'll try here.

Posting Permissions

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