LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-14-2011, 07:08 PM   #1
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 616

Rep: Reputation: 32
Question Need help to have a rsync script log output to a file with time stamp


I have the following rsync string:

Code:
# weird use of braces to capture STDERR and pipe to a file
{ time {
       rsync -av --quiet -e "ssh" --exclude="/mnt/glusterfs/upload/\*" --exclude="/mnt/glusterfs/lost\+found" root@server2:/mnt/glusterfs
       rval=$?
} } 2> ${dt}_dr_timing.txt
I need to add a variable for ${dt}_dr_timing.txt that gives the timestamp at the front of the output log. They would like the output to look like: yyyymmdd-hhmmss

How should I do this?
 
Old 11-14-2011, 07:42 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
Doesn't rsync with "--log-file=/path/to/rsync.log --log-file-format="%t\n";" work for you?
 
Old 11-15-2011, 07:41 AM   #3
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by unSpawn View Post
Doesn't rsync with "--log-file=/path/to/rsync.log --log-file-format="%t\n";" work for you?
They want (a programmer in another group) to have a separate log that they access with a script they are writing...
 
Old 11-15-2011, 04:05 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
Quote:
Originally Posted by Thaidog View Post
They want (a programmer in another group) to have a separate log that they access with a script they are writing...
I showed you how to create a separate log file the rsync way and ensure it has a suitable time stamp and I don't get what your reply signifies. And if they can't transmogrify the available time stamp to their "yyyymmdd-hhmmss" format they can be accused of much but not of being programmers.
 
Old 11-15-2011, 04:29 PM   #5
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by unSpawn View Post
I showed you how to create a separate log file the rsync way and ensure it has a suitable time stamp and I don't get what your reply signifies. And if they can't transmogrify the available time stamp to their "yyyymmdd-hhmmss" format they can be accused of much but not of being programmers.
Well the whole script has lots of quarks like:

short_host=`hostname | awk -F. '{print $1}'`

Which I think hostname -s would work better / faster... but whatever... I'll run it by them to see what they say... thanks for your help!
 
Old 11-15-2011, 05:37 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
One other way could be to output to a plain log file and let Rsyslog pick it up. This way you can apply about any formatting Rsyslog supports and even send it over to another host, say a developers machine running (R)syslog, for them to play with...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rdist using notify and a time-stamp file lewpatch Linux - General 0 07-01-2010 03:33 PM
need help with time stamp script bufo Linux - General 3 10-25-2009 02:31 AM
file time stamp is wrong with ssh file transfer cy163 Linux - Newbie 8 05-18-2008 01:40 AM
time stamp for file modification youngstorm Linux - Newbie 2 11-01-2005 03:46 PM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM


All times are GMT -5. The time now is 01:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration