odo for Mac
odo - an atomic odometer for the command line
odo — overview
odo - an atomic odometer for the command line
Atomic Odometer? What?
odo atomically updates a count in a file, which will be created if not present. The count is text-formatted (e.g. "00012345n"), and will be accurately incremented or reset even when multiple processes attempt to change the counter at the same time. (It uses memory mapping and atomic compare-and-swap operations to eliminate race conditions.)
Use cases
This could be used to track some intermittent event, like services being restarted. (This was the original inspiration.) Since the counter is just a number in a text file, it's easy to compose odo with other tools.
Dependencies
odo depends on atomic compare-and-swap functionality (e.g. __sync_bool_compare_and_swap), which is available on most common platforms. The build is currently tested on Linux, OpenBSD, and OSX on x86 and x86-64 systems, as well as on a Raspberry Pi (32-bit ARM).
If the gcc-specific feature defines in types.h are not recognized by your C99 compiler, you may need to set COUNTER_SIZE in the Makefile yourself: -DCOUNTER_SIZE=4 for 32-bit systems and -DCOUNTER_SIZE=8 for 64-bit systems.
Getting started
To build it, just type:
$ make
To install it:
$ make install
To run the tests:
$ make test
Example Use
This atomically increments a counter in /log/restarts. If the counter file does not exist, it is created as 0 and incremented to 1.
$ odo /log/restarts
Same, but print the updated count:
$ odo -p /log/restarts
Reset the count to 0:
$ odo -r /log/restarts
Set the count to a number (for testing notifications, perhaps):
$ odo -s 12345 /log/restarts
Print the current counter value without incrementing:
$ odo -c /log/restarts
Print usage / help:
$ odo -h
Note
odo's atomicity is only as reliable as the underlying filesystem's. Inconsistencies may still occur if used on a non-local filesystems such as nfs.
Details
命令行的原子里程表
How to install odo
- Open Terminal (press ⌘ + Space and type “Terminal”).
- If Homebrew is not installed yet, run the command below first.
- Run this command:
Latest 10 releases
This project has no GitHub releases yet.
Prebuilt bottle platforms
Official Homebrew bottles cover:
- Apple silicon · latest macOS
- Apple silicon · macOS 26 Tahoe
- Apple silicon · macOS 15 Sequoia
- Apple silicon · macOS 14 Sonoma
- Apple silicon · macOS 13 Ventura
- arm64_monterey
- arm64_big_sur
- Intel · macOS 14 Sonoma
- Intel · macOS 13 Ventura
- Intel · macOS 12 Monterey
- big_sur
- Linux · ARM64
- Linux · x86_64
Cannot be installed alongside: odo-dev。
To use both, first brew uninstall the conflicting package, or install it in an isolated environment.
Compared with similar apps
Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.
| App | Version | License | Architecture | 30-day installs |
|---|---|---|---|---|
| odo | 0.2.2 | ISC | CLI | 0 |
| libatomic_ops | v7.10.0 | MIT AND Boehm-GC AND GPL-2.0-or-later | CLI | 46 |
| openssl@4 | openssl-4.1.0 | Apache-2.0 | CLI | 494,798 |
| xz | v5.8.4 | 0BSD AND GPL-2.0-or-later | CLI | 346,605 |
Similar apps: Command-line Tools
libatomic_ops
The atomicops library (libatomicops)openssl@4
Cryptography and SSL/TLS Toolkitxz
General-purpose data compression with high compression ratiopkgconf
pkgconf is a program which helps to configure compiler and linker flags for development…node
Node.js is an open-source, cross-platform JavaScript runtime environment.gh
GitHub command-line toolCategories: Command-line Tools