# Unknown ruby processes show up in "top" when running cronjob

**URL:** <https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731>\
**Category:** Ruby\
**Created:** [November 20, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731 "2006-11-20T21:22:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 20, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731/1 "2006-11-20T21:22:06Z")

</div>

Hello,

I have a ruby (rails) cronjob.  
When I monitor the execution of the cronjob with top, I notice that 2  
more processes show up in there (instead of just one for my cronjob).

My cronjob captures the output of running a python script (with the  
`python script.py` syntax). Can this be the cause? Why?

Thanks for any tips

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 20, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731/2 "2006-11-20T21:42:13Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hello,
> 
> I have a ruby (rails) cronjob.  
> When I monitor the execution of the cronjob with top, I notice that 2  
> more processes show up in there (instead of just one for my cronjob).
> 
> My cronjob captures the output of running a python script (with the  
> `python script.py` syntax). Can this be the cause?

Yes.

> Why?

Because the cronjob has its own process ID (1), then it needs to execute  
the  
Python interpreter (2) which runs the Python script (3). All separate  
processes.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 22, 2006, 2:30pm UTC](https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731/3 "2006-11-22T14:30:35Z")

</div>

2006/11/20, Paul L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Yes.
> 
> > Why?
> 
> Because the cronjob has its own process ID (1), then it needs to execute the  
> Python interpreter (2) which runs the Python script (3). All separate  
> processes.

No: Python does not create two processes. However, the backtick  
command uses a sub-shell to execute the command line, so: cron  
launches Ruby (1 process), which launches “/bin/sh -c ‘python  
script.py’” (1 process), which launches Python on the script (1  
process). See the documentation for Kernel#` (the actual method  
implementing the backtick command).

If you don"t need shell-specific features (pipes and redirections) in  
the command line you execute, you can fork the Ruby process and then  
call exec to _replace_ that child process with python, thus bypassing  
the intermediate shell. It’s probably not worth the trouble though.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 22, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/unknown-ruby-processes-show-up-in-top-when-running-cronjob/76731/4 "2006-11-22T23:52:08Z")

</div>

I don’t think that’s the case, I’m talking about two more “ruby”  
processes showing up there. (Python also appears)

I created two test scripts, one in ruby that launches (with `python script.py`) the other written in python (I also put some sleep(5) calls  
in there for better observation). And as it is normal, only one “ruby”  
process appears and for the duration of the python script, a “python”  
process.

This probably has something to do with rails, but I don’t know what.

Thanks
