bs-
bs-

Reputation: 3

Unable to run X11 (graphical) programs from atd

I am trying to schedule the execution of a shell-script with the Linux tool "at". The shell script (video.sh) looks like this:

#!/bin/sh
/usr/bin/vlc /home/x/video.mkv

The "at" command:

at -f /home/x/video.sh -t 201411052225

When the time arrives, nothing happens.

I can execute the shell-script just fine via console or by rightclicking - Execute. VLC starts like it is supposed to. If I change the script to e.g. something simple like

#!/bin/sh
touch something.txt

it works just fine.

Any ideas, why "at" will not properly execute a script that starts a graphical program? How can I make it work?

Upvotes: 0

Views: 256

Answers (2)

chiastic-security
chiastic-security

Reputation: 20520

You're trying to run an X command (a graphical program) at a scheduled time. This will be extremely difficult, and quite fragile, because the script won't have access to the X server.

At the very least, you will need to set DISPLAY to the right value, but even then, I suspect you will have issues with authorisation to use the X screen.

Try setting it to :0.0 and see if that works. But if you're logged out, or the screensaver's on, or any number of other things...

(Also, redirect vlc's stdout and stderr to a file so that you can see what went wrong.)

Your best bet might be to try something like xuserrun.

Upvotes: 2

Gilles Quénot
Gilles Quénot

Reputation: 185189

I suspect that atd is not running. You have to start the atd daemon before (and to set DISPLAY variable like chiastic-security said) ;)

You can test if atd is running with

pidof atd &>/dev/null && echo 'ATD started' || echo >&2 'ATD not started

Your vlc command should be :

DISPLAY=:0 /usr/bin/vlc /home/x/video.mkv

(Default display)

Upvotes: 0

Related Questions