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 4321546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:45:35+00:00 2026-05-21T08:45:35+00:00

I’m having some difficulties to starting a background process in Ruby. I’ve this code

  • 0

I’m having some difficulties to starting a background process in Ruby.

I’ve this code right now.

#!/usr/bin/env ruby -w
require "daemons"
require 'rubygems'

path = "#{File.expand_path(File.dirname(__FILE__))}/.."

Daemons.run_proc('stalker',{
  :dir_mode => :normal,
  :dir => "#{path}/tmp/pids",
  :backtrace => true,
  :monitor => false,
  :log_output => true
}) do
  system "stalk #{path}/config/jobs.rb"
end

I then start the script using script/stalker start.

The problem is that I can’t stop it. It saves the wrong PID into the pid file.

Like this:

script/stalker start
=> stalker: process with pid **39756** started.

ps aux | grep ruby 
=> linus    **39781**   0,3  1,9  2522752  78864   ??  S     8:39pm   0:10.11 ruby stalk script/../config/jobs.rb

Why doesn’t the first pid match the one printed using ps aux | grep ruby?

I’ve tried using exec, %x{} and this one system to run the script.

  • 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-21T08:45:35+00:00Added an answer on May 21, 2026 at 8:45 am

    If you use run_proc, the code that you want daemonized should go in the block. Starting another process with system doesn’t make sense (It will fork the process (giving you yet another pid), and then exec your jobs.rb script. Either move the code from jobs.rb into the run_proc block, or use Daemons.run

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.