Bash – How to start a process with any name which does nothing

bashprocess

I want to start a process that does nothing but is still running. Say I start a process called sadhadxk, and when I run pgrep -x "sadhadxk" I will get the PID number back, like any normal process works.

So is there any way to start a dummy process?

Best Answer

You could do:

perl -MPOSIX -e '$0="sadhadxk"; pause' &

It should set both the process name and argv[0] on systems where it's supported so should show sadhadxk in both ps and ps -f output, so should be matched by both pgrep -x and pgrep -fx.