The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find and store files based on FileName and Modified Time edisonantus UNIX for Advanced & Expert Users 2 02-19-2008 02:25 PM
find formatted filename with date time dpath2o UNIX for Advanced & Expert Users 6 02-05-2008 11:20 PM
Sort files by Date-timestamps available in filename & pick the sortedfiles one by one Chindhu Shell Programming and Scripting 4 08-10-2007 07:54 AM
Insert date/time within a filename cooperman UNIX for Dummies Questions & Answers 7 11-07-2005 12:29 PM
renaming a compressed file to filename without .Z bruceps UNIX for Dummies Questions & Answers 8 08-16-2005 02:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-19-2005
wayneb wayneb is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 3
Renaming files to have date/time in filename

I have a program that will export my data to a single file, but it assigns a file name that is overridden every time I run the program. I need to change the file name to have a sequential number in the filename.
How do I rename a file so that the filename contains the system date and time. I want to run this in a script and then get crontab to execute the script.

Any one got any ideas if and how this can be done. I am running Sco OpenServer 5.0.7
  #2 (permalink)  
Old 01-19-2005
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 219
From what I could make out of your problem:
1.You have a program or an executable which creates a file
2.Every time you run the program the file created previously gets
"overwritten"
3.You want new file to get created every time you run the program in your cron.

The solution lies in changing the very program that creates the file.
If you have the code of that program then probably someone can help.

Chill
enc.
  #3 (permalink)  
Old 01-19-2005
ssmiths001 ssmiths001 is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 41
Here something I've used in the past:

cp <file name> <filename>.`date +"%Y%m%d%H%M%S"`
  #4 (permalink)  
Old 01-19-2005
wayneb wayneb is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 3
SSMITH

Thanks that works a treat
  #5 (permalink)  
Old 01-19-2005
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 219
Alternatively you could run a script in your cron right after your file is created
and in that script you could rename the file to a name you would like to have so that the program you run does not overwrite the file each time it runs.
  #6 (permalink)  
Old 01-19-2005
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
Why not always have the script put the output in a datestamped file?

For example:

Code:
#!/bin/ksh
SCRIPT=$(basename ${0})
LOG="${SCRIPT}_`date +%m%d%y%H%M%S`


command1 >> $LOG 2>&1
command2 >> $LOG 2>&1
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0