LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-25-2008, 03:34 PM   #1
chasegger
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
move a file to same location with a different extention


I have a rsyncd.log file that I would like to move on a weekly basis.
If possible I would like to take this rsycnd.log file and move it to same location with the current MMDDYY extention

ex: mv rsyncd.log rsyncd.log.062508 << How can I script to add current
date timestamp.

Thank you
 
Old 06-25-2008, 04:06 PM   #2
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 43
you can add this to where you want the date `date +%b%d_%H%M%P_%Y`


play around with the format but that will give you Jun25_1605pm_2008 format Monthdate_time_year
 
Old 06-25-2008, 04:08 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
mv rsyncd.log rsyncd.log.$(date \+\%Y%m%d)
 
Old 06-25-2008, 04:32 PM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 54
In some distributions there is a package you can install which does exactly this.
On Gentoo it is called "logrotate" - Debian has it too as well as probably many others.
Moves and compresses the logs as you configure it and can mail it too...
 
Old 06-25-2008, 07:21 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Put your distro in your profile, so we can see it. Logrotate is designed for sort of this task and most distros have it.
 
  


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
JRE will not move to location so can install... linexnal Linux - Software 4 07-17-2007 03:08 PM
how to open file with stp extention in SuSE 10.1 riba43 SUSE / openSUSE 2 07-24-2006 12:55 PM
what's find the extention of a file in linux? mcshen Linux - General 20 02-28-2005 02:16 PM
.sh install file extention matt Linux - Newbie 7 09-09-2004 04:37 AM
unpacking a (.sh) file extention. troycus Linux - Newbie 2 10-07-2003 10:52 PM


All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration