use of date in LOG FILES! how to?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting use of date in LOG FILES! how to?
# 1  
Old 07-18-2002
use of date in LOG FILES! how to?

how can i use the date command to create unique log file names? ie, trying to do backups, i want to output a listing of what was backed up to an output log file for that day:

tar cvf /dev/rmt/0 /usr/ /export/home > dateadmin.log where date would be teh current year, day month.

I'm using the korn shell, ksh environment, any help appreciated, thanks, kym
# 2  
Old 07-18-2002
date +%y%d%m will give you 021807 (for today anyway)

touch `date +%y%d%m`admin.log would create

Also, Perderabo has a datecalc script that may be useful.

Perderabo's datecalc
# 3  
Old 07-18-2002
date log file, that didn't work

I tried touch 'date +%y%m%d'admin.log and no go. Could something not be set up right in my ksh shell? I've looked through 3 books and that command should work, but does not. Any other ideas? will try the pederabo thing next.
# 4  
Old 07-18-2002
date calc

Don't think that script date calc is what i'm looking for, the date command works fine, i put in $> date +%Y%m%d and get
20020718 back, no probs, just trying to incorporate that into a redirected log file name isn't working.
# 5  
Old 07-18-2002
Check the character you are using when typing the command:

touch `date +%y%d%m`admin.log
touch 'date +%y%m%d'admin.log

Difference is ` versus '. (I copied from your post - assuming it's what you used to try the command).
# 6  
Old 07-18-2002
THANK YOU!!!!!!!!!!!!!!!!!!!!!1

Ohmigosh, i cannot believe that. i was using hte apostrophe, never paid it much attention, figured it was the difference between shell environments vs what the references i was looking at were using!!!! when i used the ` instead of apostrophe ' it worked!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!, the ` is up near the 1 on a standard pc keyboard. DOH! Thanks again
# 7  
Old 07-18-2002
'`" $()

Instead of backquote `command` use $(command)
Less change of typo's and it reads easier.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

2. Shell Programming and Scripting

Move log files with date and delete older than 3 weeks

I have written a script which generate one logfile on every sunday and thursday I want to move the older log files into /tmp directory befor generating new one so i used mv command like mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp 2) But when i move this file to /tmp it will... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

3. Shell Programming and Scripting

Extracting log files based on date and time.

Hi All, i have some log files generated in a folder daily with the format abc.def.20130306.100001 ghi.jkl.20130306.100203 abc.def.20130305.100001 ghi.jkl.20130305.100203 the format is the date followed by time . all i want is to get the files that are generated for todays... (3 Replies)
Discussion started by: mahesh300182
3 Replies

4. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

5. Shell Programming and Scripting

Monitor log entries in log files with no Date format? - Efficient logcheck?

is there a way to efficiently monitor logfiles that do not have a date or time format? i have several logs on several different servers that need to be monitored. but i realized writing a script for this would be very complex and time consuming giving the variety of things i need to check for i.e.... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

7. Shell Programming and Scripting

How to catch date and time from log files?

Hi, Appli.log files contain the below data which updates continuously ================================================== =============== Tuple Created OrderEntry|66|39.0|ADML.L|16.89|GBP||GFD|000002889 41ORLO1|GB00B02J6398|80|XLON|UHORIZON|null|2011-05-09... (11 Replies)
Discussion started by: pspriyanka
11 Replies

8. Shell Programming and Scripting

Filtering the yesterdays date from log files via script.

hi All, I have this sample text file - access.log: Jan 18 21:34:29 root Jan 18 21:34:40 root Jan 18 21:34:43 root Jan 18 21:34:56 root Jan 18 21:35:10 root Jan 18 21:35:23 root Jan 18 21:36:04 root... (2 Replies)
Discussion started by: linuxgeek
2 Replies

9. Shell Programming and Scripting

Script to copy log files with today's date

I am a newbie to scripting. I need a korn shell script to copy log files of current day to archive folder and rename with current days date stamp. I would really appreciate your help. File structure is as follows. Everyday files get overwritten, so I need copy to a archive directory and... (3 Replies)
Discussion started by: mdncan
3 Replies

10. Shell Programming and Scripting

Sorting Files by date and moving files in date order

I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
Discussion started by: rebel64
2 Replies
Login or Register to Ask a Question