0

Hello powershell scripters,

i really can't get this one...

I have fileA.log which will be filled continuously with data. Now i want to stream this file to a file B in another folder.

On Linux its like

tail -f fileA.log > anotherfolder/fileB.log 

Problem is fileA.log will be rotated two times a day into fileA.log and a new fileA.log will be created. So the script has to check if fileA.log gets rotated. If so it has to do the same with fileB.log and start a new one automaticly and continue the output from the new fileA.log to the new fileB.log.

I hope i explained it understandable. Anyone can help me out with this?

Skaos
  • 1
  • 1
    wouldn't it be easier to simply have whatever's doing the rotating simply append A to B? plus, if you're doing this to preserve the log file, why rotate+copy? that's lot of disk work when you could simply create new log files each time with a timestamp or something in the filename. – Marc B Feb 12 '16 at 16:41
  • 1
    Possible duplicate of [Unix tail equivalent command in Windows Powershell](http://stackoverflow.com/questions/4426442/unix-tail-equivalent-command-in-windows-powershell) – Phiter Feb 12 '16 at 16:42
  • Okay Problem is: FileA has to be streamed to a shared folder which is mounted on a linux server. On this Linux server runs an apache. From there FileB will be streamed with jQuery into a web page. I know it sound really really crazy but there is no other way to do it! And no i can't just share the folder which contains fileA! Sadly :( – Skaos Feb 12 '16 at 16:51
  • Have a look at the duplicate. Using the `-Wait` parameters seems to do the trick. The output file will be locked though while its in progress. – Matt Feb 12 '16 at 17:15

0 Answers0