14

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?

3 Answers 3

14

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.

10
> bash -c 'exec -a sadhadxk sleep 1000000' &

pgrep doesn't work but

> ps | grep '[s]adhadxk'
18931  [...] sadhadxk 1000000

Correction: pgrep does work but not against the command name (which is the name of the running binary), only against the command line:

> pgrep -f sadhadxk
18931
2

Try doing this :

sleep 600 &
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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