Log File too Large
Hallo,
I do have the following, rather banal problem: I'd like to direct the residuals of my simulation to a log file, in order to be able to plot them at some time. However, since my time step is very small, the log file expands quickly. I estimated that, if I run my simulation for 24 hours, the log file will have a size of approx. 3 gigabyte. So, how do you handle the size of your log files? Is there a possibility to restrict the size of the file to a certain limit, so that, for instance, only the last 1000 residuals are written? Cheers, Julian |
Quote:
julianFoam | gzip >theLog.gz or julianFoam | tail -10000 >theLog |
Bernhard,
not sure that the second option will help. I think this will simply collect the first 10000 lines, write them into theLog and then stop. However, Julian want to have the last 10000 lines dynamically. So 10-10010 which implies rewriting the file from the start. I think the system tools for log-rotation will be helpful here, but don't know more than that. Henrik |
Quote:
julianFoam | head -10000 >theLog But you're right. tail won't know the last 10k lines before the simulation ended Quote:
A workaround (beware: advertisement) that could reduce the amount of data written (but would still write all residuals so it would still be a lot of data) would be to run the solver with "pyFoamRunner.py --no-log". That would not write a log-file but extract the residuals from the standard-output and write them to the .analyzed-directory. Similar things might also work with the foamLog-etc-scripts that come with OF Bernhard |
Thank you Bernhard and Henrik for your quick reply.
I tried both commands that you posted Quote:
Quote:
Where's the Problem? Quote:
|
Bernhard,
you simply write myLog and once it contains more than x lines you flush the handle, move the file to myLog.last and start a fresh myLog. We must not use use a pipe at the exit! So something like this Code:
julianFoam | betterLogger 10000 myLog Code:
cat myLog.last myLog > myLog Actually, it should not be hard to write such a shell-filter or pyFoam? Henrik |
Quote:
Quote:
|
Quote:
I tried the command Code:
rhoCentralFoam | betterLogger 10000 myLog Code:
bash: betterLogger: command not found |
Quote:
What it already has is --compress-option for PyFoamRunner.py that writes the logfile as a gz (the compression ratio is not optimal). I'm just not sure whether it is already in the last released version |
Quote:
|
Bernhard,
you have little faith ;) Code:
#!/usr/bin/perl Julien: cut & paste the code into a text file and name is "betaLogger". Then execute chmod u+x betaLogger Code:
julianFoam | betaLogger 1000 log |
Quote:
|
Hello,
I did following step above as Henrik guide, but I met error Code:
betaLogger: command not found Thanks |
Hi,
@Hiuluom Have you tried to execute the script directly by using julianFoam | ./betaLogger 1000 log instead ? I have a question for Henrik. First of all thank you for the script. I have a problem when I use it for parallel runs, it returns a blank file. Any idea why ? The command I run is: runParallel nameofsolver nbProcs | betaLogger 1000 log |
Hi,
thanks to Henrik and Bernhard for this nice post and script, it was really helpful. I do not know if someone is still interested in this, but to run the "betaLogger" in a bash script (as faab has done I assume), I just wrote instead the "runParallel" command the proper line: Code:
mpirun -np $np solverName -parallel | ./betaLogger 1000 logFileName Cheers Hauke |
Quote:
Hi Can you rewrite it into bash? I am running my cases on remote machine and there is no perl |
Quote:
Me? Rewrite what into bash? I'm sorry: no Reasons: a) I only use bash to glue commands together. That's what it was designed for. Not "real" programming b) there is a reason that log-analysis is usually done in proper programming languages c) I don't need it and you're not a customer. These are usually the reasons why I write stuff and that is enough to fill my time |
Ok
I thought that code of betaLogger is easy to rewrite into bash thnks for reply |
All times are GMT -4. The time now is 03:15. |