Q: Bash script to launch chromium, sleep for 20 seconds, then close quietly I am trying to create a bash script that will launch chromium, wait 20 seconds, then close chromium.
This is for xbmcbuntu so I can open a site, then it will close automatically after 20 seconds (as I will have no way of closing it with just the remote control).
What I have is:
#!/bin/bash
openbox &
/usr/bin/chromium-browser
sleep 20
killall -9 openbox

Chromium opens ok, but never closes.
What am i missing?

A: Instead of killing openbox, you need to kill chromium-browser.
openbox &
openbox_pid=$!
/usr/bin/chromium-browser &
chromium_pid=$!
sleep 20
kill $chromium_pid
kill $openbox_pid

Don't use kill -9 unless it's absolutely necessary.

A: Since you are not putting chromium-browser in the background, none of the code after the chromium-browser command will execute until chromium-browser finishes execution. This should do what you want:
#!/bin/bash
openbox &
openbox_pid=$!
/usr/bin/chromium-browser &
chrome_pid=$!
sleep 20
kill "$chrome_pid" "$openbox_pid"


A: Not tested, only my idea
#!/bin/bash
openbox &
here run: script.any &    #background where script.any permission is execute and contain:
#!/bin/bash
/usr/bin/chromium-browser
from this script run browser show mode
sleep 20
killall -9 openbox
sorry my bad english
Anjoy ;)
