Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Give custom name to a process started with nohup

Tags:

bash

shell

When I create new process using exec I can give it some custom name using -a option, i.e. exec -a MyName MyCommand

Doing so facilities handling bunch of same processes started with different parameters. For instance if I have following:

exec -a MyName1 MyCommand param1
exec -a MyName2 MyCommand param2

and for some reason I want to kill a latter it's as simple as: pkill -f MyName2.

Problem is I don't know how to achieve same effect with processes started using nohup. I've read about -p option, but it's not always supported. disjoin doesn't seem to work either.

Has anybody faced similar problem?

like image 821
Mateusz Kaczor Avatar asked Nov 07 '22 05:11

Mateusz Kaczor


1 Answers

You can do like this:

nohup bash -c 'exec -a xxx sleep 12345'
like image 94
pynexj Avatar answered Nov 12 '22 12:11

pynexj