Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :

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.

share|improve this question
Why on Earth are you using xinit to have the PulseAudio daemon running? – peterph Dec 21 '13 at 14:16
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 '13 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 '13 at 14:51
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 '13 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 '13 at 14:57

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

share|improve this answer
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. – Michael Kjörling Dec 21 '13 at 16:35
thanks, I did not know user-specific crontab files exist. kursus, are you talking about /etc/crontab? – Thorsten Staerk Dec 21 '13 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. – Gilles Dec 21 '13 at 23:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.