I am running program using runit to run at startup. I want all the output by from the program that is run by runit to be logged to a file.
I have looked at svlogd but I cannot figure out how to get it running.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
I cannot figure out how to get it running.
In the daemontools family world, log services are just services like any other. So you run
svlogd with a
run program just like you would run a "main" service with a
The special things about "log" services are merely that:
Otherwise, they are just like everything else.
So make a "log" service to run
svlogd just like you would make any other service, put it into the right place relative to your "main" service, and set things off.
The first thing you have to do is to find out where runit files are on your system. Usually it's
/etc/runit/. There, you'll find a directory called
sv in which one directory per service is created.
Let's say you want to create a new service called
food. You would create create a directory called
# mkdir /etc/runit/sv/food
run script in
/etc/runit/sv/food. Let's say that your service's program is an executable at
/opt/bin/foo. In that case your
run script will be this.
#!/bin/sh exec /opt/bin/foo 2>&1
For logging, you should create another directory in
log. And in it another
#!/bin/sh exec svlogd -tt <logs-directory>
Make sure the
<logs-directory> exits. And don't forget to make both
run scripts executables.
# chmod +x /etc/runit/sv/food/run # chmod +x /etc/runit/sv/food/log/run
Make a symbolic link of your
food directory inside
# ln -s /etc/runit/sv/food /etc/runit/runsvdir/default/
To manually start/stop your service simply run:
# sv start food # sv stop food
Take a loot at this quick start guide for more details.
Notice that unlike the guide, I didn't use
chpst in my example. In this case the
food service will run as
chpst as suggested by the guide if you want your service to run as a specific user.