rsync shell script which saves log

Posted on 2006-05-15
Last Modified: 2006-11-18
Hi Experts,

I need to rsync a "docs" directory from machine1 to machine2. How do I put a log file into the destination, in a folder called rsync-logs with the date and time included? (somewhat like rdiff-backup?)

So that I can have a listing similar to this:

    increments.2006-05-03T01:30:01-07:00.dir   Wed May  3 01:30:01 2006
    increments.2006-05-04T01:30:01-07:00.dir   Thu May  4 01:30:01 2006
    increments.2006-05-05T01:30:01-07:00.dir   Fri May  5 01:30:01 2006
    increments.2006-05-08T01:30:01-07:00.dir   Mon May  8 01:30:01 2006
    increments.2006-05-09T01:30:01-07:00.dir   Tue May  9 01:30:01 2006
    increments.2006-05-10T01:30:01-07:00.dir   Wed May 10 01:30:01 2006
    increments.2006-05-11T01:30:01-07:00.dir   Thu May 11 01:30:01 2006
    increments.2006-05-12T01:30:01-07:00.dir   Fri May 12 01:30:01 2006
    increments.2006-05-13T01:30:02-07:00.dir   Sat May 13 01:30:02 2006

Thanks in advance!

Question by:sow56091
    LVL 3

    Expert Comment

    I asssume you want to:
         rsync from machine1 to machine2
        put a log of the transfer on machine2?

    You can easily do it in a script which first runs rsync, redirecting the log
    to a file, then rsync-ing the log file to whatever you want to call it...

    I think!!
    LVL 3

    Author Comment

    Yes, I agree, but how do I store the current date/time in a variable and refer to the that in bash script for my cron job?

    LVL 38

    Accepted Solution

    >>but how do I store the current date/time in a variable and refer to the that in bash script for my cron job?

    you can do:


    # format the date time in var:
    CTIME=`date +%Y%m%d%H%M`


    CTIME=`date +%Y%m%d%H%M`

    #create a log with time stamp
    myscript > /path/to/log.$CTIME  2>&1


    use cron to run your script.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now