bash + at, 29 bytes
at now+$[$1/60]min<<<bash\ $0
zsh + at, 28 bytes
at now+$[$1/60]min<<<zsh\ $0
bash + at or zsh + at, 23 bytes, arguably cheating
at now+$[$1/60]min<<<$0
The first version re-executes the program after the number of seconds given as a command-line argument (which must be a multiple of 60 because at
has only minute granularity). at
is a standard POSIX program for scheduling programs to be run in the future. The 29-byte and 28-byte programs each rerun the program with the shell it's designed for. The 23-byte program doesn't specify a shell, and thus may well accidentally rerun it with sh
, which is likely to be unable to parse it; it's up to you whether you consider it reasonable for the restart to happen in the wrong language or not, so I presented both versions.
The time to wait is taken as a command-line argument. This means that the argument won't be present in the rerun, and thus the rerun will exit (with an error message due to the malformed expression, but which will be hidden by at
; on some systems, it might be sent to you by email, but mine doesn't have that set up) rather than keep rerunning indefinitely.
bash
considers the $[]
syntax for arithmetic obsolete, but it still works and is shorter than the "official" syntax. zsh
is fine with it, as far as I could tell from the documentation.