LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-07-2007, 07:43 AM   #1
dolphs
Member
 
Registered: Nov 2003
Posts: 51

Rep: Reputation: 15
Question Add time stamp to file minus one day


Hi,

I have the following in a cron script running:

/usr/bin/mv $[location]/logfiles.tar.gz $BACKUP/backuplogs`date +%Y_%m_%d`.tar.gz

This is fine so far, but instead of having the current day I like to have it one day back, so eg instead of "backuplogs2007_11_07.tar.gz" it should be " backuplogs2007_11_06.tar.gz"

How to achieve this please?

Last edited by dolphs; 11-07-2007 at 07:48 AM.
 
Old 11-07-2007, 07:54 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Some examples:
Code:
date -d "1 day ago" +%Y_%m_%d
date -d "yesterday" +%Y_%m_%d
date -d "today - 1 day" +%Y_%m_%d
See info date for details. Cheers!
 
Old 11-07-2007, 08:07 AM   #3
dolphs
Member
 
Registered: Nov 2003
Posts: 51

Original Poster
Rep: Reputation: 15
yes unfortunately it concerns a solaris box on which I have limited rights, so we need to think of something else, cheers anyway!
 
Old 11-07-2007, 10:17 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Uh... yeah, this was an useful information: indeed on solaris the date command does not have the -d option. First of all, have you the GNU command installed on the solaris box? You may check for example
Code:
which gdate
ls /usr/sfw/bin
ls /usr/gnu/bin
ls /usr/xpg4/bin
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename file based on its own date/time stamp airman99 Linux - General 19 09-05-2006 07:52 AM
Script to change date in filename minus one day ft77 Linux - General 3 06-02-2006 09:56 AM
Time stamp Kalyani1 Linux - Software 0 11-07-2005 02:58 PM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:48 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