linux shell, keep task alive for specified time
- by liori
Hello,
I am looking for a tool to keep a task alive (restarting if necessary) for a specified amount of time (in seconds), and then kill it and stop. For example: keep_for 3600 rsync foo bar:faz should for try to synchronize a directory (restarting rsync in case of f.e. dropped connection), but explicitly kill rsync and stop respawning it after an hour.
I tried to write a shell script for that, but it was surprisingly difficult to write, with lots of edge cases (like child process not getting killed, or shell escaping issues). So... maybe there already is a tool for that?