17.10.2016 18:33, Bob Williams пишет:
I have a bash script to generate the sig featured below.
#!/bin/bash
# script to generate a topical linux mailsig
SIGFILE=/home/bob/Documents/Signatures/daily.sig
: > $SIGFILE # (re)creates an empty SIGFILE
echo "Bob Williams" >> $SIGFILE echo " System: " `uname -sr` >> $SIGFILE distro=" $(head -n 1 /etc/SuSE-release)" kde=`kf5-config -v | grep KDE` Qt=`kf5-config -v | grep Qt` plasma=`kcmshell5 -v | awk '{print $2}'` echo " Distro: $distro" >> $SIGFILE echo " Desktop: $kde, $Qt and Plasma: $plasma" >> $SIGFILE exit 0
When run from my user command line it works correctly, but when I run it from my crontab, it fails to get the plasma version. So the last line of output reads:
Desktop: KDE Frameworks: 5.26.0, Qt: 5.6.1 and Plasma:
The error message returned by the system is:
QXcbConnection: Could not connect to display
I'm guessing that cron is not running in graphical environment, but not sure why that would make a difference.
How do you expect it to get version of graphical environment if there is no graphical environment to start with?
Can anyone suggest a solution/workaround, please?
Do not use cron. If your script depends on presence of DE, run it when you are logged in DE. It's not as this information changes so often, so running it once on login would be enough. Otherwise you could of course export DISPLAY in cron command, but you may not even be logged in when cron task is executed.