I have two production red hat servers hosting a PHP web form. Let’s call them serv1 and serv2. Both servers host the same data (for redundancy and load bearing) and pull info from the same database.
I have a simple log.txt that generates a on a given user input. The issue is if the user is logged into serv1 it will save the log file to serv 1 the same for serv 2. I would like to be able to dump the contents of the log file on a PHP page for the admins but it only works in a one server scenario. I.e if your logged into serv1 you will see only logs from events which happened on serv1.
My idea is to sync the files between each server. So no matter which server the event comes from the log files will remain synced. I was thinking of using the php string exec command to execute a "Linux red hat script" to merge and save the txt files on both servers.
What I don't know is the "Linux red hat script" part. I have come across this scp *.txt email@example.com:/home/user/ but am not sure how I would go about using it.
Pre-empting questions: Doing this through the database at this stage is not possible given
The access required and change management required would ultimately result in management giving up on the little venture.