tryto(1)
π 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 sendTERMtoprogto sec seconds. Default is180. three whole minutes of patience, very generous of her ngl-k ksecβ kill timeout. Set the timeout to sendKILLtoprogto ksec seconds. Default is5. five seconds to wrap it up before things get real-n triesβ Set the maximal number of tries to tries. Ifprogexited with a return code other that 0,trytotries to rewind standard input to the beginning usinglseek(2)before startingprogagain. Default is5. rewind the tape, run it back, we go again π-pβ processor. Use this option if you runtrytoas asvlogd(8)processor (see below). iykyk-Pβ process group. Runprogin a new session and process group, and send signals on timeout toprog'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,trytomoves the filedescriptor5to2, so all error messages fromtrytoandprogwill be saved insvlogd(8)'s state to be processed on the next run oftryto -p. fd glow-up: 5 β‘οΈ 2 β¨ - After starting
prog,trytofirst feeds all data it reads from filedescriptor4intoprog's standard input, then all data from filedescriptor0. 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
trytoitself fails, it returns111. not her fault, something else went wrong π - If
trytoruns as asvlogd(8)processor,trytoreturns0in all other cases. - If
progwas run successfully,trytoreturns0. ate. no crumbs. π - If
progfailed by timeout,trytoreturns100. clock ran out β° - If
progfailed by maximal number of tries,trytoreturns the last return code fromprog. she hands you the exact receipts fromprog'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
- nixpkgs unstable: socklog 2.1.2
- ubuntu resolute: socklog 2.1.2+repack-1 Β· BSD-3-Clause
- ubuntu stonking: socklog 2.1.2+repack-3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms