Simple but useful sysadmin tools

Sysadmins offen happen upon simple tasks for which there’s no actual shell command. For example, you may want to run a command after a random delay of up to 3 minutes. Well, there’s sleep and there’s $RAND, so you’ll probably quickly solve that problem. If you need to do this more often, you’ll likely build some kind of script to make this task as easy as possible.

Being an awesome sysadmin, Steve Kemp not only wrote a bunch of small sysadmin tools for frequent needs but also published them on Github:

  • ago: Show how long ago a file/directory was modified in a human-readable fashion.
  • dupes: Report on duplicate files, via a SHA1 hash of the contents, recursively.
  • empty-dir: Indicate, via return code, whether a given directory is empty or not.
  • maybe: In a similar vain to true and false the maybe command exits with a status code of zero or one, depending on a random number.
  • multi-ping: Ping a host, regardless of whether it is an IPv6 or IPv4 host.
  • mysql-slave-check: If the current host is a MySQL slave this script will test that the slave replication is still working.
  • randpass: Generate a single random password via /dev/urandom.
  • since: Show the new output since previously reading a file. This is useful for keeping track of logfile updates.
  • splay: Sleep for a random amount of time, limited by the given max value. (Default is 5 minutes).
  • ssl-expiry-date: Report the date, and number of days, until the given SSL certificate expires.
  • timeout: Timeout allows you to run a command which will be killed after the given number of seconds.
  • until-success: Repeat the specific command until it succeeds – run at least once always.
  • which-shell: Identify the shell we’re running under.
  • with-lock: Run a command, unless an existing copy of that command is already running, via the creation of a temporary lockfile.

Thanks, Steve!