我的crontab设置如下
*/3 * * * * /usr/local/bin/checkHomeAssistant >> /dev/null 2>&1
checkHomeAssistant脚本检查“shopList”进程是否打开,否则我想关闭正在进行的每个chrome进程并启动homeAssistant脚本。 这是代码
#!/bin/bash
#lo script che esegue nell’ambiente crontab (non X) deve sapere in che ambiente grafico deve agire e con quali variabili d’ambiente
export DISPLAY=:0
export XAUTHORITY=/home/pi/.Xauthority
checkShopList=$(ps –ef | grep –v grep | grep –c shopList)
checkChromium=$(ps –ef | grep –v grep | grep –c chromium-browser)
if [ $checkShopList –eq 0 ]; then
if [ $checkChromium –eq 1 ]; then
pkill chromium
sleep 5
fi
/home/pi/Desktop/homeAssistant
fi
homeAssistant脚本
#!/bin/bash
sleep 5
/home/pi/Documents/QTProjects/shopList/build/ShopList &
chromium-browser --app=http://www.dakboard.com --start-maximized &
chromium-browser http://www.google.com --start-maximized &
#xvkbd -geometry 700x300 -compact minimizable $
sleep 5
wmctrl -r "DAKboard" -t 0
wmctrl -r "MainWindow" -t 1
wmctrl -r "Google - Chromium" -t 2
wmctrl -s 0
我的问题是checkHomeAssistant脚本与铬的杀戮相混淆:并不总是所有的问题都被杀死,有时候它会杀死它们...... 建议?