Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
timewizard
· 1y ago · 0 comments
<command> & sleep <timeout>; kill -SIGALRM %1
Comments
[–]
robinhouston
1y ago
That's ok, but %1 will refer to the wrong job if there's already a background job running. You could use %% instead, but that will refer to the wrong job if <command> terminates before the timeout.
[–]
fpoling
1y ago
This always sleep for timeout rather than terminating when the command terminates.