【问题标题】:Error in spawning a dbus-launch - what is that?生成 dbus-launch 时出错 - 那是什么?
【发布时间】:2013-12-15 15:31:03
【问题描述】:

我喜欢像这样运行一个 cron 来为摄像头拍摄快照:

* 9-17 * * 1-5 vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/foo/tmp/cam --scene-prefix snapshot --scene-format png vlc://quit --run-time=1

但是当 cron 运行时它只会抛出一个我不明白的错误:

** Message:
Failed to get session bus:
Error spawning command line 'dbus-launch --autolaunch=55644972b3c91c1d24d83d8252721f00 --binary-syntax --close-stderr':
Child process exited with code 1

在网上我找不到干净或好的文档是什么。你能帮我弄清楚吗?

【问题讨论】:

    标签: linux ubuntu terminal cron v4l2


    【解决方案1】:

    据我所知,您可能需要:

    1. 设置显示变量(注意可能不是0,可能是1甚至是2):

      export DISPLAY=:0
      
    2. 启动一个 dbus 会话:

      dbus-launch
      
    3. 设置dbus变量:

      export $(dbus-launch)
      

    在您使用 Cron 作业的情况下,您可以像这样设置环境变量:

    env VARIABLE=VALUE <command>
    

    因此,对于选项 1,您的工作将如下所示:

    * 9-17 * * 1-5 env DISPLAY=:0 vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/foo/tmp/cam --scene-prefix snapshot --scene-format png vlc://quit --run-time=1
    

    对于选项 3,您可以使用 && 分隔两个命令,如下所示:

    * 9-17 * * 1-5 dbus-launch && vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/foo/tmp/cam --scene-prefix snapshot --scene-format png vlc://quit --run-time=1
    

    选项 2 的类似内容:

    * 9-17 * * 1-5 export $(dbus-launch) &&vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/foo/tmp/cam --scene-prefix snapshot --scene-format png vlc://quit --run-time=1
    

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多