flock
« Back to VersTracker
Description:
Lock file during command
Type: Formula  |  Tracked Since: Dec 28, 2025
Links: Homepage  |  formulae.brew.sh
Category: Developer tools
Tags: cli locking concurrency utility sysadmin
Install: brew install flock
About:
Flock is a command-line utility that manages file locks via the flock(2) system call. It executes a command while holding an exclusive or shared lock on a specified file, preventing concurrent access to critical resources. This ensures safe coordination for scripts and processes operating on shared files or devices.
Key Features:
  • Manages exclusive and shared file locks
  • Executes commands within the lock context
  • Supports non-blocking and timeout modes
  • Works with file descriptors for advanced scripting
Use Cases:
  • Preventing concurrent cron jobs from overlapping
  • Ensuring exclusive access to shared resources in shell scripts
  • Rate limiting or serializing access to external services
Alternatives:
  • lockfile-progs – Higher-level lockfile creation with retry logic, but not tied to command execution.
  • mkdir (as lock) – A simple atomic lock mechanism but lacks robust features like timeouts and shared locks.
Version History
Detected Version Rev Change Commit
Sep 13, 2025 5:16pm 0 VERSION_BUMP 9a42f676
Dec 27, 2024 2:17pm 0 VERSION_BUMP 2b4f689e