shell script to replicate the log files from one location to another in real time

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script to replicate the log files from one location to another in real time
# 1  
Java shell script to replicate the log files from one location to another in real time


On the server, we have app log files in this location /app/logs/error.log
On the same server, in a real time, we would like to replicate that into /var/ directory.

if someone has already done this, please share the script.

Thanks in advance.
# 2  
This can be done in a variety of ways.

One of the quick and easy way:
tail -f source_file > dest_file

This process must be continuosly running.
This User Gave Thanks to Shell_Life For This Post:
# 3  
how about make a link ?
ln -s /app/logs/error.log /var/error.log

hard/soft link depends on your requirement.
This User Gave Thanks to sk1418 For This Post:
# 4  
Should the two logfiles be exact copies of each other or do you will to append any new log entries that are added to /app/logs/error.log to /var/error.log?

Will any other processbe writing to the /var/error.log file?
What should happen if the /app logfile is truncated?
# 5  
Thanks all to provide the useful information.

Let me give some more background

There are two physical servers which are tie to a SAN disk. One server is active[A] and the other is standby[B].At any given time, only active server has mount to the san disk which means access to /app/logs/error.log

If active server has problem, then it will failover to standby server and that server become active and will have access to /app/logs/error.log

The idea is

1) if server A is active, and app is generating the logs in error.log, then copy that into server A /var/error.log. so lets say if there are three errors 1,2,3, then it should copy those three into var/error.log on server A

2) if server B is active, and app is generating the logs in error.log, then copy that into server B /var/errorl.log. so lets say if there are new errors 4,5,6, then it should copy those new errors into var/error.log on server B.

The error.log file never rollback / truncated. it just keep growing.

Not sure how to handle this situation. if the error.log file is too big and someone decided to archive and empty the file.

i think we need some well structured shell script
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #723
Difficulty: Medium
Niklaus Emil Wirth, an Austrian computer scientist, designed several programming languages, including Pascal,
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying the files in to multiple location using shell script

Hi All, i'm trying to copy the 1.txt files (sample files) in to different path location using the below command. But it is not copying the files , when i tried for single location able to copy the file. can any one please assist here. Please find the below path :- /ckr_mkr1/licencekey... (2 Replies)
Discussion started by: venkat918
2 Replies

2. Shell Programming and Scripting

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 Replies

3. Shell Programming and Scripting

Archiving or removing few data from log file in real time

Hi, I have a log file that gets updated every second. Currently the size has grown to 20+ GB. I need to have a command/script, that will try to get the actual size of the file and will remove 50% of the data that are in the log file. I don't mind removing the data as the size has grown to huge... (8 Replies)
Discussion started by: Souvik Patra
8 Replies

4. Shell Programming and Scripting

[solved] How to see log in real time?

Hi people I have a bash script with a line like this: python >> log & But i can't see anything in the log file while python program is running only if the program ends seems to write the log file. "$ cat log" for example don't show anything until the program ends. Is there... (4 Replies)
Discussion started by: Tieso
4 Replies

5. HP-UX

HP-UX real time audit log writing

Hey all, I have a problem I was hoping to get some help on. So I have my two auditfiles, audfile1 and audfile2 that can be written to, I want to have the text version of them write to an NFS mount that I have set up. So i already know that i can do .secure/etc/audsp audfile1 > //nfsmount/folder/... (5 Replies)
Discussion started by: CleverRiver6
5 Replies

6. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

7. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

8. Shell Programming and Scripting

Perl or Shell script to read a transaction log in real time

Hello, I have a Apache webserver running on RedHat. Its primary function is a proxy server for users accessing the internet. I have a transaction log that logs every transactions of every users. For users trying to access certain sites/content the transactions goes into a 302 redirect loop and... (2 Replies)
Discussion started by: bruno406
2 Replies

9. Shell Programming and Scripting

Real time log file redirect

Hi all, i would like to write the shell script program, it can monitor the access_log "real time" when the access_log writing the line contain "abcdef" the program will be "COPY" this line into a file named "abcdef.txt", do the same thing if the contain "123456" "COPY" it into a file named... (3 Replies)
Discussion started by: eric_wong_ch
3 Replies

10. UNIX for Dummies Questions & Answers

log users real time

hi.... how i can configurator a log file on real time....on unix solaris.... thanks a lot.... Best Regards... (3 Replies)
Discussion started by: chanfle
3 Replies

Featured Tech Videos