Shell Scripts – How to Run an Application for a Set Time

command linescripts

If and How is it possible to, in Terminal, to get an application to run for 30 seconds, before being force closed, and echoing the logs of that process?

Best Answer

You might want to use the timeout command.

timeout -k 10s 30s command

which will run the command for 30s and kill it after 10s if still running. - Check the manpage for more options.

Related Question