2

I have a command that works perfectly when launched from the prompt:

xinit /home/user/myscript.sh -- /usr/bin/Xvfb :1 -screen 0 1x1x8

But is not executed when put in crontab:

@reboot xinit /home/user/myscript.sh -- /usr/bin/Xvfb :1 -screen 0 1x1x8

Content of myscript.sh :

#!/bin/sh
dbus-launch
pulseaudio --start
sleep 99999999

See output of htop, command is weirdly executed:

enter image description here

Even though the X session is active on reboot.

8
  • 1
    Why on Earth are you using xinit to have the PulseAudio daemon running?
    – peterph
    Dec 21, 2013 at 14:16
  • 1
    Because Pulseaudio needs dbus, and dbus needs X. Without X, Pulseaudio can only run in system mode, which is bad as the official website says : freedesktop.org/wiki/Software/PulseAudio/Documentation/User/…
    – kursus
    Dec 21, 2013 at 14:46
  • That's not true. I run pulseaudio as a non-privileged user on a system without X or dbus; it complains ([pulseaudio] core-util.c: Failed to connect to system bus) but it runs normally. However, I'm not sure how it well it will work within X if you then start X up.
    – goldilocks
    Dec 21, 2013 at 14:51
  • 1
    If your DBus depends on X, consider changing distribution since it is seriously flawed. The opposite is (unfortunately) true however - latest desktops do depend on DBus. Even for pulseaudio I think the dependency is not hard (i.e. you can run it without DBus connection).
    – peterph
    Dec 21, 2013 at 14:57
  • Well it doesn't work on my system (Raspbian), PA clearly says "Can't run without X session" and it actually doesn't work. With the xvfb trick it works perfectly. Any suggestion ?
    – kursus
    Dec 21, 2013 at 14:57

1 Answer 1

-1

You are missing the information which user your command should run under, better do:

@reboot root xinit /home/user/myscript.sh -- /usr/bin/Xvfb :1 -screen 0 1x1x8

had a similar problem and put it here: http://www.linuxintro.org/wiki/Scheduling_tasks#crontab

3
  • 1
    That depends. If it is in a user-specific crontab file, then you don't need and absolutely do not want the username field. If it's in a system crontab file, then you do need to specify the username. The question doesn't seem to say which.
    – user
    Dec 21, 2013 at 16:35
  • thanks, I did not know user-specific crontab files exist. kursus, are you talking about /etc/crontab? Dec 21, 2013 at 18:01
  • The command is executed by user pi, so that line is obviously in pi's crontab, not in a system crontab. Even without this clue, if the line was in a system crontab, cron would complain that the user xinit doesn't exist and it wouldn't execute anything. Dec 21, 2013 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .