简体   繁体   English

无法从atd运行X11(图形)程序

[英]Unable to run X11 (graphical) programs from atd

I am trying to schedule the execution of a shell-script with the Linux tool "at". 我正在尝试使用Linux工具“ at”安排执行shell脚本。 The shell script (video.sh) looks like this: Shell脚本(video.sh)如下所示:

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

The "at" command: “ at”命令:

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. 我可以通过控制台或右键单击-执行来执行shell脚本。 VLC starts like it is supposed to. VLC以预期的方式启动。 If I change the script to eg 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? 有什么想法,为什么“ at”不能正确执行启动图形程序的脚本? How can I make it work? 我该如何运作?

You're trying to run an X command (a graphical program) at a scheduled time. 您正在尝试在计划的时间运行X命令(图形程序)。 This will be extremely difficult, and quite fragile, because the script won't have access to the X server. 这将非常困难,而且非常脆弱,因为脚本将无法访问X服务器。

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. 至少,您需要将DISPLAY设置为正确的值,但是即使如此,我怀疑您在使用X屏幕的授权方面也会遇到问题。

Try setting it to :0.0 and see if that works. 尝试将其设置为:0.0 ,看看是否可行。 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.) (此外,将vlc的stdout和stderr重定向到文件,以便您可以查看出了什么问题。)

Your best bet might be to try something like xuserrun . 最好的选择是尝试使用xuserrun之类的东西

I suspect that atd is not running. 我怀疑atd没有运行。 You have to start the atd daemon before (and to set DISPLAY variable like chiastic-security said) ;) 您必须先启动atd守护程序(并设置DISPLAY变量,如chiastic-security所述);)

You can test if atd is running with 您可以测试atd是否与

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

Your vlc command should be : 您的vlc命令应为:

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

(Default display) (默认显示)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM