Table of Contents

What Is It?

lockf is a piece of software that comes with FreeBSD (as well as other BSDs, I would assume). It's a simple C program that allows you to create a lock file with an exclusive lock and start a program running. Here is the man page. It's a simple program with a simple implementation that is very useful. This was written by John D. Polstra, copyright 1997, and I have taken the source and modified it so that it will work on linux systems.

Why Use It?

This is very helpful when running a cron job that might run long enough that it would “overlap” with the next cron run. This will cause the overlapping instance to exit, alternatively after -t <seconds> timeout.