logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

timeout.1 (1822B)


  1. .\" utils-std: Collection of commonly available Unix tools
  2. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. .\" SPDX-License-Identifier: MPL-2.0
  4. .Dd June 18, 2025
  5. .Dt TIMEOUT 1
  6. .Os
  7. .Sh NAME
  8. .Nm timeout
  9. .Nd run a command with a time limit
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Op Fl fp
  13. .Op Fl k Ar duration
  14. .Op Fl s Ar SIGNAL
  15. .Ar duration
  16. .Ar command
  17. .Op Ar argument...
  18. .Sh DESCRIPTION
  19. The
  20. .Nm
  21. utility executes
  22. .Ar command
  23. and terminates it, if still running after
  24. .Ar duration .
  25. .Pp
  26. .Ar duration
  27. is a string containing non-negative decimal numbers including floats, terminated by a suffix: s for seconds, m for minutes, h for hours, d for days.
  28. If the final number doesn't have a suffix it is assumed to be seconds.
  29. Longer durations are taken as out of scope.
  30. .Sh OPTIONS
  31. .Bl -tag -width __
  32. .It Fl f
  33. Disables killing child processes.
  34. .It Fl k Ar duration
  35. Enables sending a
  36. .Dv SIGKILL
  37. after
  38. .Ar duration .
  39. .It Fl p
  40. Preserve (mimic) the wait status of
  41. .Ar command ,
  42. even after
  43. .Ar duration .
  44. .It Fl s Ar SIGNAL
  45. Signal to be sent on timeout, by default
  46. .Dv SIGTERM
  47. is sent.
  48. Signal may be a name like 'HUP' or 'SIGHUP', or a number like '9'.
  49. .Pp
  50. A list of signals may be obtained with
  51. .Cm kill
  52. .Fl l .
  53. .El
  54. .Sh EXIT STATUS
  55. The
  56. .Nm
  57. utility may return one of the following statuses:
  58. .Pp
  59. .Bl -tag -width 111 -compact
  60. .It 124
  61. Timeout reached
  62. .It 125
  63. Error within
  64. .Nm
  65. .It 126
  66. Failed to execute
  67. .Ar command
  68. .El
  69. .Pp
  70. Otherwise, the exit status of
  71. .Ar command
  72. is returned.
  73. .Sh SEE ALSO
  74. .Xr kill 1 ,
  75. .Xr sleep 1
  76. .Sh STANDARDS
  77. .Nm
  78. should be compliant with the
  79. IEEE Std 1003.1-2024 (“POSIX.1”)
  80. specification.
  81. .Sh HISTORY
  82. A
  83. .Nm
  84. utility appeared in SATAN, Netatalk, GNU Coreutils 7.0,
  85. .Ox 7.0 ,
  86. .Nx 7.0 ,
  87. .Fx 10.3 ,
  88. IEEE Std 1003.1-2024 (“POSIX.1”).
  89. .Sh AUTHORS
  90. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me