Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm pretty new to runit. I installed it on a Ubuntu host.

What I did:

1) created a dir testrun in /etc/sv

2) created a script run in /etc/sv/testrun/run, the script content:

#! /bin/bash
exec /root/FP/annotate-output python /root/FP/ | logger -t svtest

3) If I call directly /etc/sv/testrun/run it executes successfully

4) I run sv start testrun (or sv run testrun, sv restart testrun), all of them end up with the same error msg:

fail: sv: unable to change to service directory: file does not exist

Any ideas what am I doing wrong? I'm new to runit and base all my actions on the information found here:

share|improve this question

2 Answers 2

Your service isn't set up correctly. The reason it worked is that you invoked it directly from the service definition and not from the actual service control.

When runit's service management starts, it expects a /service directory to exist, although some installs (like Debian Jessie) currently have it at /etc/service for reasons unknown. The error message comes from this missing directory, which it is trying to change to, hence the unable to change service directory message. Do the following as root:

mkdir -p /etc/service
cd /
ln -s /etc/service
cd /service
ln -s /etc/sv/testrun

This will:

  • create the service directory if it doesn't exist
  • place a symlink in the root so that runsvdir will be able to change to /service as its working directory
  • creates a link to your testrun service, assuming you have it defined at /etc/sv/testrun

runsvdir will then be able to change its directory into /service, find your symlink for testrun, and then launch it. You can verify this by using ps fax or pstree -A to see the process tree; there should be a runsv with your command attached to it. Note: sometimes it may take a second or two for the runsvdir process to get its head oriented, so if you look right away and don't see it in the process tree, wait 2-3 seconds and try again, and it should show up. This appears to only happen when it starts up.

share|improve this answer
A side note: if you look at the stage 2 script in Debian Jessie (2014-08-20 as of this writing), you'll see that it invokes runsvdir with /service instead of /etc/service. If you don't like having the symlink for /service around in the root of the filesystem, simply change the stage 2 script to /etc/service and it will be "correct" on the next reboot. –  Avery Payne Aug 20 '14 at 18:59
up vote 0 down vote accepted

It seems that sv controls services that are started and monitored by runit (using runsv). As runit on my machine does not actually replace sysvinit, it does not run and does not monitor the /services/ which should contain symbolic links to /etc/sv/ directories.

Running runsv /etc/sv/testrun/ seems to do the expected runit behavior.

share|improve this answer
This is the wrong answer, but I don't downvote out of principle. –  Avery Payne Aug 20 '14 at 18:44

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.