timer.1 (1750B)
- .\" SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+cmd-timer@hacktivis.me>
- .\" SPDX-License-Identifier: MPL-2.0
- .Dd June 18, 2025
- .Dt TIMER 1
- .Os
- .Sh NAME
- .Nm timer
- .Nd run command at a specific interval
- .Sh SYNOPSIS
- .Nm
- .Op Fl w
- .Op Fl c Ar clockid
- .Ar interval
- .Ar command
- .Op Ar arguments...
- .Sh DESCRIPTION
- The
- .Nm
- utility runs
- .Ar command
- at every
- .Ar interval .
- .Pp
- The
- .Ar interval
- argument is a string containing non-negative decimal numbers including floats,
- terminated by suffixes:
- s\ for\ seconds, m\ for\ minutes, h\ for\ hours, d\ for\ days.
- .br
- If the final number doesn't have a suffix, seconds are assumed.
- Longer durations are taken as out of scope.
- .Pp
- If
- .Ar command
- exits with a non-zero status,
- .Nm
- exits with the same status,
- allowing to use service supervision to track failures.
- .Sh OPTIONS
- .Bl -tag -width Ds
- .It Fl c Ar clockid
- Set the clock to be used for the timer.
- The
- .Ar clockid
- argument can be set to one of the following shortcodes:
- .Bl -tag -compact -width __
- .It r
- CLOCK_REALTIME (default)
- .It m
- CLOCK_MONOTONIC
- .It b
- CLOCK_BOOTTIME
- .It ra
- CLOCK_REALTIME_ALARM
- .It ba
- CLOCK_BOOTTIME_ALARM
- .It t
- CLOCK_TAI
- .El
- .Pp
- See
- .Xr timer_create 3
- for the behavior of each clock.
- Note that only CLOCK_REALTIME and CLOCK_MONOTONIC are portably
- defined in POSIX.1-2024.
- .It Fl w
- Wait for
- .Ar interval
- to elapse.
- Otherwise
- .Nm
- immediately runs
- .Ar command
- after starting.
- .El
- .Sh EXIT STATUS
- .Ex -std
- .Sh EXAMPLES
- .Bl -bullet
- .It
- Run
- .Cm munin-cron
- every 5 minutes:
- .Nm
- .Ar 5m munin-cron
- .It
- Print bell every minute and a half:
- .Nm
- .Ar 1m30s printf '\ea'
- .El
- .Sh SEE ALSO
- .Xr at 1 ,
- .Xr crontab 1 ,
- .Xr sleep 1 ,
- .Xr timer_create 3
- .Sh AUTHORS
- .An Haelwenn (lanodan) Monnier Aq Mt contact+cmd-timer@hacktivis.me