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?
Here are two ways (but the
timeout command suggested by mcantsin is probably better):
Launch the command in the background, that way its PID is saved in
$!and you can use that to kill it after the specified time:
command & sleep 30 && kill $!
Launch the command and use
killallto kill it. CAUTION: This assumes that only one command with that name is running, I am using
firefoxas an example:
firefox & sleep 30 && pkill firefox
I have no idea what you mean by "the logs of that process" but a process's standard error can be saved to a file with
command 2> logfile.txt.