Table of Contents

Name

actionwhenfileold - exec a command if a file gets too old

Synopsis

actionwhenfileold /path/to/file max-age-in-minutes /path/to/command [arg(s)]

Description

actionwhenfileold tests if the file’s modification time is older than max-age-in-minutes. It does this every ten seconds. If the file is too old then actionwhenfileold forks and executes the command. actionwhenfileold sleeps ten seconds. Then it checks the status of the command. If it still runs then actionwhenfileold sends it a kill-signal and sleeps again.

actionwhenfileold is designed to run forever. If it has trouble on fork() or running /path/to/command it prints a message to stderr; it will try again ten seconds later.

actionwhenfileold does not need a configuration file or resource config. The usage of Dan Bernstein’s daemontools is recommended.

actionwhenfileold has a small memory footprint and uses low resources. Compiled with dietlibc and sstripped its size is below 1 KB.

Examples

This example shows the restart of a service if it’s locked up:

$ actionwhenfileold /path/to/lockfile 5 /etc/init.d/myprog restart

Author

Frank Bergmann, http://www.tuxad.com


Table of Contents