I have a Leap 15.4 KDE system full updated. I have four Windows programs running using wine and can start them fine using a .desktop file and the program(s) start and run using a Wine virtual desktop window. I have installed dex which works also to start these programs with this command in a Konsole window
dex WXSIMate.desktop > /dev/null 2>&1
and the WXSIMate program starts and runs fine with no additional output in the Konsole window.
Now I need to run these programs on a timed basis and thought a cron job would work using the above command. I created a cron job for my user using the Task Manager panel in KDE systemsettings and when I list it in the user crontab it looks like
and runs OK when I execute it manually from systemsettings (using the Run Now button), unfortunately it leaves a Konsole window open with an end of script message which I have to close manually. However when left to run on schedule at 15:17 nothing seems to happen and the program does not start.
So is there anything obvious that I have missed or something I need to do differently to make this work?
I have no idea running Wine or related stuff, but in a cron job you better define all files with absolute path. So when WXSIMate.desktop is a file, then better add the complete path (like you did with /usr/bin/dex).
You can test what cron would do by running env -i /usr/bin/dex /home/stuart/Desktop/WXSIMate.desktop > /dev/null 2>&1
i.e. with an empty environment. Usually, environment variables have to be defined in the crontab. See man 5 crontab. You should be able to tell from the output of the env command which variables those are.
And apart from the good hint to find out if environment variables are needed, you seem to expect output that you send to /dev/null. Instead sending to a file and inspecting the file could give some clue.
OK so if I run env -i as suggested it fails to start and says it can’t find a display. However the command without the env works and starts the program in a Wine Desktop window and runs. If I leave out the bit about /dev/null etc it does produce some messages but nothing which stops the program from starting OK in the Wine Desktop window.
There is obviously enough defined in the .desktop file for the program to run it. All I’m trying to do is to be able to schedule running it in a cron job.
That can not be correct. That is an export command, not a command with an added environment variable before it. I assume you mean 17 15 * * * DISPLAY=:0 /usr/bin/dex WXSIMate.desktop > /tmp/mycrontab.log 2>&1
But yes, this is probably the old case of startimg a program in the background that then wants to opena window in a desktop that may be available or not.
Many people to not understand that Unix/Linux is a multi-user/multi-session operating system. Thus there can be none, one, two, more sessions open at the same time, those sessions belonging to different users.
And even if one of those sessions is chosen (with the DISPLAY variable) then still the session owner must probably allow outside programs to open windows (see 'xhost +`).
The second adds the variable only to the execution of the echo command.
The third is in fact two commands of which the first creates the variable in the current process and exports it to all eventual child processes; the second shows it to prove that it is in the environment.
Making it more complicated by using the && (why not simply a ; ? Are you afraid that the export fails?) is not needed. As I show it to you in the earlier post, it will only add the variable and it’s value to the environment of the process started by the command and only to that process, not polluting the current process.
Same for that what we advice to many to show command output in English on systems with another language:
LANG=LC zypper lr -d
The LANG=LC is in the environment of zypper without changing anything in the current environment.
And yes, xhost is a security hole. As is the very fact that someone wants even to try to open a window from outside a GUI session as the OP here seems to want.