I've been running ptpd with "-f Log.txt" option for logging purposes. Since I've got a limited disc space I would like to clear the log once in a while. So, I came up with two solutions: to simply remove the file or to clear it's contents.
If I do a simple "rm Log.txt", the log is deleted but ptpd doesn't create a new one. On the other hand, if I clear the contents (with a simple "echo "" > Log.txt" or smth like that), the log contents are discarded and file size is set to "0". However, next time when ptpd writes something in the log, file size is increased at the same value like it was before I cleared it.
I presume ptpd has an opened filehandle or lock on the log file, so my question is - is there a way to clear the log (and reduce it's size) without shutting down ptpd? I can always do a simple "kill ptpd -> remove Log -> start ptpd" procedure, but I'd like to avoid it (if it is possible ofc).
Tnx in advance ..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you happened to come up with an elegant solution for this?
I too am looking at the same problem.
I tried to use the "-V NUMBER" parameter, to at least slow down the growth of the log file. However, it doesn't appear to work (or I don't understand exactly what it's supposed to do).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've been running ptpd with "-f Log.txt" option for logging purposes. Since I've got a limited disc space I would like to clear the log once in a while. So, I came up with two solutions: to simply remove the file or to clear it's contents.
If I do a simple "rm Log.txt", the log is deleted but ptpd doesn't create a new one. On the other hand, if I clear the contents (with a simple "echo "" > Log.txt" or smth like that), the log contents are discarded and file size is set to "0". However, next time when ptpd writes something in the log, file size is increased at the same value like it was before I cleared it.
I presume ptpd has an opened filehandle or lock on the log file, so my question is - is there a way to clear the log (and reduce it's size) without shutting down ptpd? I can always do a simple "kill ptpd -> remove Log -> start ptpd" procedure, but I'd like to avoid it (if it is possible ofc).
Tnx in advance ..
Have you happened to come up with an elegant solution for this?
I too am looking at the same problem.
I tried to use the "-V NUMBER" parameter, to at least slow down the growth of the log file. However, it doesn't appear to work (or I don't understand exactly what it's supposed to do).
Why don't just use logrotate? Logrotate can keep your log down to a certain maximum, rotate and compress the old logs (or not if you choose not to).
Even if it's an embedded system, it should be possible to enable logrotate somehow. Even a shell script and cron could do the job in fact.