Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8432135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:02:38+00:00 2026-06-10T06:02:38+00:00

I am writing a Log Unifier program. That is, I have a system that

  • 0

I am writing a Log Unifier program. That is, I have a system that produces logs:
my.log, my.log.1, my.log.2, my.log.3…

I want on each iteration to store the number of lines I’ve read from a certain file, so that on the next iteration – I can continue reading on from that place.

The problem is that when the files are full, they roll:
The last log is deleted
…
my.log.2 becomes my.log.3
my.log.1 becomes my.log.2
my.log becomes my.log.1
and a new my.log is created

I can ofcourse keep track of them, using inodes – which are almost a one-to-one correspondence to files.

I say “almost”, because I fear of the following scenario:
Between two of my iterations – some files are deleted (let’s say the logging is very fast), and are then new files are created and some have inodes of files just deleted. The problem is now – that I will mistake these files as old files – and start reading from line 500 (for example) instead of 0.

So I am hoping to find a way to solve this- here are a few directions I thought about – that may help you help me:

  1. Either another 1-to-1 correspondence other than inodes.

  2. An ability to mark a file. I thought about using chmod +x to mark the file as an
    existing file, and for new files that don’t have these permissions – I will know they are new – but if somebody were to change the permissions manually, that would confuse my program. So if you have any other way to mark.

  3. I thought about creating soft links to a file that are deleted when the file is deleted. That would allow me to know which files got deleted.

  4. Any way to get the “creation date”

  5. Any idea that comes to mind – maybe using timestamps, atime, ctime, mtime in some clever way – all will be good, as long as they will allow me to know which files are new, or any idea creating a one-to-one correspondence to files.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:02:40+00:00Added an answer on June 10, 2026 at 6:02 am

    I can think of a few alternatives:

    • Use POSIX extended attributes to store metadata about each log file that your program can use for its operation.

    • It should be a safe assumption that the contents of old log files are not modified after being archived, i.e. after my.log becomes my.log.1. You could generate a hash for each file (e.g. SHA-256) to uniquely identify it.

    • All decent log formats embed a timestamp in each entry. You could use the timestamp of the first entry – or even the whole entry itself – in the file for identification purposes. Log files are usually rolled on a periodic basis, which would ensure a different starting timestamp for each file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing log statements to a file and want to prepend each line with
I have a WCF service that is responsible for writing a log file. I
I'm writing a program that parses the log files of a Windows service. The
I'm writing a distributed system which logs directly to database (actual log files are
I am writing a Log Viewer,that will be able to show logs between two
I am writing something that will allow users to search through a log of
I am writing a server in PHP where I want to log all database
I have a web server that host several PHP applications and I want to
I'm interested in writing a log file analyzer that can determine the percentage of
We are writing log files to File.applicationDirectory and want to clean out old log

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.