Read more

Linux: Running a single unique instance of command + arguments

Dominik Schöler
March 07, 2017Software engineer at makandra GmbH

run-one is a wrapper script that won't run the given command while another instance of it is running. Is brings several utility commands that offer similar behavior.

NAME
       run-one - run just one instance at a time of some command and unique set of arguments (useful for cronjobs, eg)

SYNOPSIS
       run-one COMMAND [ARGS]

       run-this-one COMMAND [ARGS]

       run-one-constantly COMMAND [ARGS]

       keep-one-running COMMAND [ARGS]

       run-one-until-success COMMAND [ARGS]

       run-one-until-failure COMMAND [ARGS]

DESCRIPTION
       run-one is a wrapper script that runs no more than one unique instance of some command with a unique set of arguments.

       This is often useful with cronjobs, when you want no more than one copy running at a time.

       run-this-one  is  exactly  like run-one, except that it will use pgrep(1) and kill(1) to find and kill any running processes owned by the user
       and matching the target commands and arguments.  Note that run-this-one will block while trying to kill matching processes, until all matching
       processes are dead.

       run-one-constantly operates exactly like run-one except that it respawns "COMMAND [ARGS]" any time COMMAND exits (zero or non-zero).

       keep-one-running is an alias for run-one-constantly.

       run-one-until-success  operates exactly like run-one-constantly except that it respawns "COMMAND [ARGS]" until COMMAND exits successfully (ie,
       exits zero).

       run-one-until-failure operates exactly like run-one-constantly except that it respawns "COMMAND [ARGS]" until COMMAND exits with failure  (ie,
       exits non-zero).
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Internally Show archive.org snapshot , it hashes command+arguments and flocks on the hash.

Posted by Dominik Schöler to makandra dev (2017-03-07 11:07)