Spooling a log file with timestamp


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Spooling a log file with timestamp
# 1  
Old 03-23-2004
Spooling a log file with timestamp

Hi
From shell script i am invoking sqlplus to connect to oracle database and then i spool a csv file as with output. What i want to do is to change the file name with timestamp on it so after spooling finish shell script change file name with time stamp.
can someone help me to do that .

Thanks
UKADMIN
# 2  
Old 03-23-2004
Well, if I understand you correctly, this is easy. After your shell script logs into Oracle and runs your sql, then disconects, use a mv command to rename your file.
%T gives a time format inmilitary time like 21:01:54

SPOOL-NAME=blah-blah-blah
NEW-FILE-NAME=$SPOOL-NAME_$(date +'%T').csv


mv $SPOOL-NAME $NEW-FILE-NAME
# 3  
Old 03-23-2004
Use the date command to generate output file name, e.g...

NAME=`date +extract_%Y-%m-%d_%H:%M:%S.csv`
echo output file is $NAME
sqlplus args > $NAME

See man date for formatting
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Filter records from a log file based on timestamp

Dear Experts, I have a log file that contains a timestamp, I would like to filter record from that file based on timestamp. For example refer below file - cat sample.txt Jan 19 20:51:48 mukul-Vostro-14-3468 systemd: pam_unix(systemd-user:session): session opened for user root by (uid=0)... (6 Replies)
Discussion started by: mukulverma2408
6 Replies

2. UNIX for Beginners Questions & Answers

Script not spooling in the designated file.

Hi, I need to write a script that will run a simple select count(*) query and sends the result of that query to me via email. Here's what I already have. #!/bin/ksh ###################################################################### # File Name : counts.sh # Created : 2019/27/19... (1 Reply)
Discussion started by: clef
1 Replies

3. Shell Programming and Scripting

Bash Script Closest Timestamp (LOG FILE)

Hi All, I need something where I could take the date from FILE1 and in this case the date is Thu Sep 10 13:48:42 EDT 2015 and I need it to match the closest PREVIOUS date in the log file FILE2 this means in this specific case it would be Thu Sep 10 2015 13:35:28. I only need the closest... (3 Replies)
Discussion started by: roberto999
3 Replies

4. Shell Programming and Scripting

Script not spooling in result file

Hi everyone and nice to meet you :) I'm having some issues with a script I'm writing. It's probably most chaotic, I'm no ksh guru, but the idea is to extract an ID with that query, spool it into a file, and read that file making the ID a variable. This has to be done for every row extracted by... (10 Replies)
Discussion started by: Arkadia
10 Replies

5. Shell Programming and Scripting

prepend timestamp to continiously updating log file

Hi, I have a process which outputs to a log. Below is the code snippet: process &> $LOGFILE& The log file keeps on updating whenever a transaction is processed. The log file has a time stamp added so every time I kill the process and start the process a new log file is... (4 Replies)
Discussion started by: rajkumarme_1
4 Replies

6. Shell Programming and Scripting

Spooling file to excel

Hi , Im spooling file from oracle to csv using shell script. Below is the code im using.. The o/p is not coming in right format.. Please help me out in this.. O/p is coming as header till batch id ,im not able to see date_stored,type,type1.. Please any one can give me some suggestion ... (1 Reply)
Discussion started by: jkumsi
1 Replies

7. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

8. UNIX for Dummies Questions & Answers

Creating a Tar file while files are spooling

Hi I have done a search for this but couldn't find much on it. I am creating a tar file with the command below tar cvf /export/home/user/backup/*Will this is being created I have a job spooling to 5 texts files in the following directory /export/home/user/backup/STATS/ The tar files... (1 Reply)
Discussion started by: sgarvan
1 Replies

9. Shell Programming and Scripting

concatenate log file lines up to timestamp

Hi, Using sed awk or perl I am trying to do something similar to https://www.unix.com/shell-programming-scripting/105887-sed-awk-concatenate-lines-until-blank-line-2.html but my requirement is slightly different. What I am trying to accomplish is to reformat a logfile such that all lines... (4 Replies)
Discussion started by: AlanC
4 Replies

10. UNIX for Advanced & Expert Users

Copy lines from a log file based on timestamp

how to copy lines from a log file based on timestamp. INFO (RbrProcessFlifoEventSessionEJB.java:processFlight:274) - E_20080521_110754_967: rbrAciInfoObjects listing complete! INFO (RbrPnrProcessEventSessionEJB.java:processFlight:197) - Event Seq: 1647575217; Carrier: UA; Flt#: 0106; Origin:... (1 Reply)
Discussion started by: ranjiadmin
1 Replies
Login or Register to Ask a Question