Skip to content

Comment on Website hosted on a 24 year old Linux serverparent

Comments

I think you can avoid the lock and all else, if all you need is a counter: Open a file in append mode (O_APPEND) and then write a byte for each visit. To get the count take the file size.

Of course you have to make sure to not run out of diskspace or max file size of the OS/filesystem (2GB on a 32bit system?)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.