Linux command that spawns multiple processes

command lineprocess

I am looking for a linux command (like ls, time or anything similar) that spawns multiple processes. Anything which is to be run from a command line and not a shell script.

The reason is I want to see parent-child relationship on the htop and with different Process IDs.

Thanks

Best Answer

The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:

$ sleep 5 & pstree -p $$
[1] 13369
bash(13337)─┬─pstree(13370)
            └─sleep(13369)

The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.

Related Question