logo

cmd-timer

run command at a specific interval git clone https://anongit.hacktivis.me/git/cmd-timer.git

timer.1 (1750B)


  1. .\" SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+cmd-timer@hacktivis.me>
  2. .\" SPDX-License-Identifier: MPL-2.0
  3. .Dd June 18, 2025
  4. .Dt TIMER 1
  5. .Os
  6. .Sh NAME
  7. .Nm timer
  8. .Nd run command at a specific interval
  9. .Sh SYNOPSIS
  10. .Nm
  11. .Op Fl w
  12. .Op Fl c Ar clockid
  13. .Ar interval
  14. .Ar command
  15. .Op Ar arguments...
  16. .Sh DESCRIPTION
  17. The
  18. .Nm
  19. utility runs
  20. .Ar command
  21. at every
  22. .Ar interval .
  23. .Pp
  24. The
  25. .Ar interval
  26. argument is a string containing non-negative decimal numbers including floats,
  27. terminated by suffixes:
  28. s\ for\ seconds, m\ for\ minutes, h\ for\ hours, d\ for\ days.
  29. .br
  30. If the final number doesn't have a suffix, seconds are assumed.
  31. Longer durations are taken as out of scope.
  32. .Pp
  33. If
  34. .Ar command
  35. exits with a non-zero status,
  36. .Nm
  37. exits with the same status,
  38. allowing to use service supervision to track failures.
  39. .Sh OPTIONS
  40. .Bl -tag -width Ds
  41. .It Fl c Ar clockid
  42. Set the clock to be used for the timer.
  43. The
  44. .Ar clockid
  45. argument can be set to one of the following shortcodes:
  46. .Bl -tag -compact -width __
  47. .It r
  48. CLOCK_REALTIME (default)
  49. .It m
  50. CLOCK_MONOTONIC
  51. .It b
  52. CLOCK_BOOTTIME
  53. .It ra
  54. CLOCK_REALTIME_ALARM
  55. .It ba
  56. CLOCK_BOOTTIME_ALARM
  57. .It t
  58. CLOCK_TAI
  59. .El
  60. .Pp
  61. See
  62. .Xr timer_create 3
  63. for the behavior of each clock.
  64. Note that only CLOCK_REALTIME and CLOCK_MONOTONIC are portably
  65. defined in POSIX.1-2024.
  66. .It Fl w
  67. Wait for
  68. .Ar interval
  69. to elapse.
  70. Otherwise
  71. .Nm
  72. immediately runs
  73. .Ar command
  74. after starting.
  75. .El
  76. .Sh EXIT STATUS
  77. .Ex -std
  78. .Sh EXAMPLES
  79. .Bl -bullet
  80. .It
  81. Run
  82. .Cm munin-cron
  83. every 5 minutes:
  84. .Nm
  85. .Ar 5m munin-cron
  86. .It
  87. Print bell every minute and a half:
  88. .Nm
  89. .Ar 1m30s printf '\ea'
  90. .El
  91. .Sh SEE ALSO
  92. .Xr at 1 ,
  93. .Xr crontab 1 ,
  94. .Xr sleep 1 ,
  95. .Xr timer_create 3
  96. .Sh AUTHORS
  97. .An Haelwenn (lanodan) Monnier Aq Mt contact+cmd-timer@hacktivis.me