I am using delayed_jobs to run Ruby classes, how can the Ruby detect the name (command) of the process that is running it?
any thoughts?
I am using delayed_jobs to run Ruby classes, how can the Ruby detect the name (command) of the process that is running it?
any thoughts?
You can determine the name of the file using $0
. You can even set the process name using it like so $0 = 'foo'
Dave Thomas's blog post. If you want to get the command line args, you want to look at ARGV
.
$0
Contains the name of the script being executed. (May be assignable so it can go wrong)
--replace-progname
switch manipulates $0 for this very purpose, so the $0 == __FILE__
magic incantation in the script being run still works. –
Aestivate If you are are using Unix system you can execute script from ruby to determine process like this:
`ps aux | grep ruby`
and then use $? to get the process
© 2022 - 2024 — McMap. All rights reserved.
$0
variable is aliased by$PROGRAM_NAME
– Kennethkennett