tryto(1)

πŸ“¦
version 2.1.2 Β· 2 versions
, in nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– tryto(1) β€” the "bestie, just try again" page πŸ’–

okay so we're in the General Commands Manual section, and today's main character is tryto β€” the little runit-adjacent icon that runs a command for you, watches it like a hawk, and is fully prepared to yell "TRY AGAIN" at it. Also it can clock in as an svlogd(8) processor. Slay. πŸŽ€


✨ NAME ✨

tryto β€” tries to run a command limited by a timeout or number of tries, can be used to run as svlogd(8) processor.

yes bestie, that's the whole vibe: bounded attempts, bounded time, no chaos.


✨ SYNOPSIS ✨

tryto [-pPv] [-t sec] [-k ksec] [-n tries] prog

✨ DESCRIPTION ✨

prog consist of one or more arguments. (yep, the manpage says "consist", we're keeping it, it's iconic πŸ’…)

tryto runs and watches prog, and it feeds its own standard input straight into prog's standard input. sharing is caring fr fr

If prog exits with a return code other then 0, tryto runs prog again after sleeping one second. one whole second of nap time, as a treat 😴

If the number of retries reaches the maximal number of tries, tryto prints an error message and gives up. rip. it tried. it's done. πŸ’€

If the timeout sec seconds is reached and prog is still running, tryto sends a TERM signal to prog, waits ksec seconds for prog to terminate, then sends a KILL signal if prog still is there, and exits as soon as possible. escalation queen πŸ‘‘ TERM first, KILL if you're still being dramatic.


✨ OPTIONS ✨

  • -t sec β€” timeout. Set the timeout to send TERM to prog to sec seconds. Default is 180. three whole minutes of patience, very generous of her ngl
  • -k ksec β€” kill timeout. Set the timeout to send KILL to prog to ksec seconds. Default is 5. five seconds to wrap it up before things get real
  • -n tries β€” Set the maximal number of tries to tries. If prog exited with a return code other that 0, tryto tries to rewind standard input to the beginning using lseek(2) before starting prog again. Default is 5. rewind the tape, run it back, we go again πŸŒ€
  • -p β€” processor. Use this option if you run tryto as a svlogd(8) processor (see below). iykyk
  • -P β€” process group. Run prog in a new session and process group, and send signals on timeout to prog's process group instead of its pid. whole squad gets the signal, not just the one guy πŸ‘―
  • -v β€” verbose. Print verbose messages to standard error. she's talking now πŸ—£οΈ

✨ PROCESSOR ✨

If tryto sees the -p option, tryto runs as a svlogd(8) or multilog(8) processor, making use of filedescriptors 4 and 5:

  • Before starting prog, tryto moves the filedescriptor 5 to 2, so all error messages from tryto and prog will be saved in svlogd(8)'s state to be processed on the next run of tryto -p. fd glow-up: 5 ➑️ 2 ✨
  • After starting prog, tryto first feeds all data it reads from filedescriptor 4 into prog's standard input, then all data from filedescriptor 0. fd 4 first, then fd 0, in that exact order, no cap

If prog fails by timeout sec seconds or maximal number of tries, tryto prints all data from standard input to standard output, an error message to standard error, and exits with 0. she saves the receipts and dips gracefully 🫢


✨ EXIT CODES ✨

  • If tryto itself fails, it returns 111. not her fault, something else went wrong 😭
  • If tryto runs as a svlogd(8) processor, tryto returns 0 in all other cases.
  • If prog was run successfully, tryto returns 0. ate. no crumbs. πŸ’…
  • If prog failed by timeout, tryto returns 100. clock ran out ⏰
  • If prog failed by maximal number of tries, tryto returns the last return code from prog. she hands you the exact receipts from prog's last attempt

✨ SEE ALSO ✨

socklog(8), uncat(1), svlogd(8), multilog(8), lseek(2)

https://smarden.org/socklog/ https://smarden.org/runit/


✨ AUTHOR ✨

Gerrit Pape <pape@smarden.org> the legend himself 🫑


and that's the whole page bestie!! πŸ¦‹ this one comes to you from the socklog / runit fam over at the smarden.org links up there β€” go say hi, tell them tryto sent you πŸ’– periodt βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from