Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6923953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:36:06+00:00 2026-05-27T10:36:06+00:00

I have a specific script written in Ruby that needs root privileges. Most of

  • 0

I have a specific script written in Ruby that needs root privileges. Most of the other processes don’t need that and so were easy to setup in Monit. Not this one.

The server needs to listen at 386, and this port is only available for root. I won’t get into the details of why, because 1) I’m not a low-level kind of guy, 2) It worked fine so far when using sudo.

The monit configuration file is simple and looks like this:

set logfile syslog facility LOG_daemon # Default facility is LOG_USER
set mailserver smtp.sendgrid.net
        username "blah", password "blah"
        with timeout 20 seconds
set alert blah@bleh.com
set logfile /home/deploy/monit.log


check process ldapserver
     with pidfile /var/pids/ldap_server.pid
     start program = "/usr/local/bin/ruby /var/lib/ldap_server.rb"
     stop program = "/bin/sh"

Note: I’ve put /bin/sh in the stop program because there’s not a stop program for this process.

If I put like this:

start program = "/usr/local/bin/ruby /var/lib/ldap_server.rb"

It fails to start. No hints.

start program = "/usr/bin/sudo -u deploy /usr/local/bin/ruby /var/lib/ldap_server.rb

Fails as well. No output.

start program = "/bin/su deploy -c '/usr/local/bin/ruby /var/lib/ldap_server.rb'

Fails to start.

I also tried redirecting the output using > ~/out.log 2 > &1 to capture stderr and stdout but it doesn’t seem to work.

Now, I’m starting monit under the deploy user, which is restricted. So, I’d need to somehow run the ldap server as root, but turns out it’s quite hard to do.

Could someone enlighten me ?

Cheers,

M>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:36:07+00:00Added an answer on May 27, 2026 at 10:36 am

    Using sudo or su to run the script as the ‘deploy’ user won’t help (as monit is already running as that user anyway, and it needs to run as root).

    Also, sudo will by default prompt for a password, which monit won’t be able to provide.

    One way to solve this would be to create a file /usr/bin/startLDAPServer.sh and make it executable (chmod a+x /usr/bin/startLDAPServer.sh) with the following contents:

    #!/bin/sh
    /usr/local/bin/ruby /var/lib/ldap_server.rb
    

    and then add this line to your /etc/sudoers file:

    deploy ALL =NOPASSWD:/usr/bin/startLDAPServer.sh
    

    You can then use:

    start program = "/usr/bin/sudo /usr/bin/startLDAPServer.sh"
    

    in monit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a php script that returns an arbitrary number of specific ids
I have some script in my default page that redirects users to language specific
I have a utility build script that gets called from a variety of project-specific
I have written a php script that generates a list of links that match
I have a script on a shared host that uses suPHP. I need unbuffered
I have a PHP script that moves files out of a specific folder on
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').
I have a specific changeset that I want to rollback my Development branch to,
I have a specific requirement that all children of a particular JComponent have double
I have a specific question, that could use a general answer... When building Multi-Tier

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.