I am trying to set up a Thin Ruby application server on my Ubuntu VPS. I have created a specific account, installed rbenv under it along with all gems.

I am looking for a convenient way to obtain the following objectives:

  1. Run my Thin Rack application under my non-privileged user account.
  2. Make the application run as a daemon
  3. Have the daemon run automatically whenever the system boots
  4. Make the daemon restartable
  5. Make the application accessible to Nginx through a unix domain socket.

Objective two and three are the trickiest. Is it possible to define scripts for a user to be run as that user whenever the system boots?

  • The short answer is YES. I do assume that you have and you WILL need support from your server admin to do this.
    – mdpc
    Jun 12, 2013 at 19:58
  • 1
    I don't have any server admin to consult. I am trying to become my own server admin.
    – Niels B.
    Jun 12, 2013 at 20:33
  • are you implying you have or have NOT root access?
    – mdpc
    Jun 12, 2013 at 20:44
  • 1
    I do have root access to my VPS, but I don't want to litter the root account with rbenv, ruby interpreters and gems. And I want the non-privileged thin account to be able to restart the daemons. If I use init.d, it seems the thin account needs to be a sudoer to have its way.
    – Niels B.
    Jun 12, 2013 at 20:50

2 Answers 2


For starting at boot time add a line to your users crontab file (using crontab -e):

@reboot /path/to/your/script with parameters

The actual contents of that script vary with your needs. It might just start the daemon, or it might start a somewhat more intelligent agent that you pass a configuration. That way you can have your service automatically restarted if it for some reason dies unexpectedly.

  • It is tempting to me to give +1 because I didn't know that is possible. But somehow I don't think that this is a good idea for managing daemons... Jun 12, 2013 at 19:40
  • actually it is possible, with a process manager I have done so on various constellations. It is IMHO one of the nicer ways to start things that do not need root permissions at any time (compared to starting from /etc/init.d)
    – Anthon
    Jun 12, 2013 at 19:41
  • This is an interesting option that I am experimenting with now. It looks promising.
    – Niels B.
    Jun 12, 2013 at 20:34
  • @NielsB. How did it work for you? I just tried this and confirmed that @reboot only works for root: unix.stackexchange.com/a/109805/28712 Thanks.
    – Withheld
    Jan 17, 2014 at 18:44
  • @Daniel, it works for normal users too. Keep in mind that the script is run AS that user in that user's environment.
    – Niels B.
    Jan 17, 2014 at 19:14

You just need adapt the start script template of your distro. I am sure everyone has such templates.

If you use systemd then you can give the user to be used in the unit file.

If you use the old init scripts then the script probably uses startproc or start_daemon. You can add parameters to these wrappers for configuring the user ID.

Or you make the program SUID (not for root but the intended user) and restrict the execution rights to trusted users (or root only).

You must log in to answer this question.

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