简体   繁体   中英

Run Chromium from shell script (Raspberry Pi)?

I am writing a script to check and restart wifi on a raspberry pi. It should also kill and relaunch chromium. I have set a job to run every minute from crontab, that command is:

*/1 * * * * /usr/local/bin/checkwifi.sh

Inside of checkwifi.sh:

ping -c4 192.168.1.1 > /dev/null

if [ $? != 0]
then
    sudo /sbin/ifdown 'wlan0'
    sleep 5
    sudo /sbin/ifup --force 'wlan0'
    sudo pkill chromium
    sleep 10
    /usr/bin/chromium --kiosk "http://some-website-here"
fi

Everything up to launching chromium works, including killing any running instance of chromium. The last line errors out silently, or at least I haven't found any error logging.

Additionally, if I run...

/usr/local/bin/checkwifi.sh

...from terminal, it works fine.

Any ideas?

Just from top of my head, maybe problem is the display environment value?

Try 'export DISPLAY=:0.1' or whatever display number your Xorg has.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM