Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I launch a process so that it would have a specific identifier in ps command?

UPD: I have a couple of servers running on one box. Most of them are in deployment mode. However one is in development. All servers are Pythonic and the disease is that all the servers are listed as python in ps, which makes it impossible to killall the one in development leaving others intact.

UPD: As David and GNUix suggested I created symlinks to Python interpreter and bash scripts for each server.

share|improve this question

You could rename the binary you're going to run. You might get away just using a symlink to the binary.

If you really want to change the name, the best way is to use a simple wrapper that sets argv and then execs the process you want to run. Don't have time to give you some example code now, but shout loudly in about 10 hours and I'll see what I can do.

share|improve this answer
exactly my point. You need code for that (aside from renaming/(sym)linking the binary which could be problematic if it checks for argv[0]) – Server Horror Jun 10 '09 at 11:10
Some binaries won't work well if you do mostly embedded (busybox, dropbear) – nhed Feb 19 '15 at 1:30

Creating a symlink should do the trick, however, it would be more helpful if we knew the disease and not the symptom. What exactly are you trying to do? Because there may be a better way

my weird program name
  PID TTY          TIME CMD
 7805 pts/1    00:00:00 zsh
14020 pts/1    00:00:00 0012
14021 pts/1    00:00:00 ps
(~)ln -s 0012 weird
my weird program name
  PID TTY          TIME CMD
 7805 pts/1    00:00:00 zsh
14046 pts/1    00:00:00 weird
14047 pts/1    00:00:00 ps

Update: Based on the extra information you could (I'm sure there is an easier way but its not comming to me at the moment) have your servers write out their PID to a file upon startup, then you could kill -9 | cat /var/run/ but then that would be a programming question :)

Update again: You could also do some shell trickery to get the PID of the servers when you launch them, off the top of my head you could create a shell function called startmyserver for example that would wrap the command you use to start your servers but also capture $! to a file based upon startup name -- then we are talking about shell scripting which is 'inbounds' @ ServerFault. :-)

share|improve this answer

This doesn't really belong on SO because it's generic, not a language specific question.

The short answer is not easily. That is, it can't be done from within the functionality of your shell or procfs/sysfs. You will need to use an external utility to achieve it.

There is a long description on how and why here. Beware it's pretty C-centric.


They're python which changes the game. Without now being too SO, it would probably be easier to modify them to make use of this module or a similar approach.

share|improve this answer
touche.. I knew there was an easier way :) – GNUix Jun 10 '09 at 11:58
The C code is considerably more verbose than it needs to be due to the amount of outputting it does. It should be possible to shrink it down, but it's doing pretty much the same as I was suggesting. Only with some code to go with it :) The bit it's missing is the exec to run your code :) – David Pashley Jun 10 '09 at 13:16

Look at It allows you to set the process name of any process using an anvironment variable.


Run Java with the LD_PRELOAD and PROCNAME environment variables set:

LD_PRELOAD=/path/to/ PROCNAME=hello java -jar foo.jar

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.