Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I’ve got a Debian web server that I’m using for occasional screen-scraping via Selenum and Python.

I use Xvfb as a virtual X server for Firefox to run on when being controlled by Selenium. Given that I (think) I have to start this using sudo, I don’t think it’ll be feasible to start it from Python each time (see my Stack Overflow question), so I figured I could just have it running all the time.

I currently start it like this at the command line:

sudo Xvfb :99 -nolisten tcp -fbdir /var/run

What method should I use to do this automatically at startup? Should I use cron, as suggested here?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

On debian, you can add the Xvfb command to /etc/rc.local. If Xvfb doesn't detach itself into the background, use an & on the end of the command.

Using cron would work too, although init scripts give you more control over exactly when in the startup sequence it will run, and are the traditional way of starting services.

share|improve this answer
    
Aha, excellent. Is editing /etc/rc.local preferred to using update-rc.d with one’s own individual scripts? –  Paul D. Waite Apr 1 '11 at 21:36
2  
@Paul I would say update-rc.d is preferred and is certainly more capable, but rc.local is quicker and easier. Also, I think Gilles is right, there's no reason this needs to run as root. –  Andy Apr 1 '11 at 22:31

Your premise is invalid: there is no reason to run Xvfb as root. Your usual X server only needs to run as root (on many but not all unices) only so that it can access the video hardware; that's not an issue for Xvfb by definition.

If you want to run Xvfb at startup, you can use cron with @reboot replacing the five date-and-time fields. You can do that in any user's crontab, not just root's. But I don't see the point. Your scripts would be more robust if you started Xvfb when you need it, just the way you seem to have originally planned it.

share|improve this answer

Your Answer

 
discard

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.