0

I'm trying to open Chromium from a bash script. This script can be executed in any moment / at the moment scheduled in crontab. I'm using Debian 9.

This script kills Chromium if the script is executed with the parameter off, and opens it if the parameter is on.

Executing the script from the terminal manually works, but using crontab / using PHP shell_exec() function as the same user used in the terminal won't work.

This is the bash script. The log is empty. Chromium won't open. ¿Any suggestion?

#!/bin/bash
if [ $1 == 'off' ]
then
echo "Chromium OFF"
pkill -x -15 chromium
else
echo "Chromium ON"
chromium http://localhost/shopCaseCodeigniter/selectSlideshowForScreen/1 --kiosk --password-store=basic > /home/miguel/Scripts/logs/chromium.log 2>&1
fi

1 Answer 1

-1

The solution was to add export DISPLAY=:0 to the script:

#!/bin/bash
if [ $1 == 'off' ]
then
echo "Chromium OFF"
pkill -x -15 chromium
else
echo "Chromium ON"
export DISPLAY=:0
chromium http://localhost/shopCaseCodeigniter/selectSlideshowForScreen/1 --kiosk --password-store=basic > /home/miguel/Scripts/logs/chromium.log 2>&1
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .