0

To run the process at boot time, I wrote a script in the rc.local file using the sudo command.

However, if you look up processes with the ps command, there are two processes, one with the sudo command and one without.

It doesn't affect the actual operation, but I wonder why two processes are created.

example

root       430     1  0 12월02 ?      00:00:00 sudo python3 process.py
root       511   423  0 12월02 ?      00:04:54 python3 process.py

can you answer me?

  • The duplicate doesn’t address the process tree shown by your `ps` output, as explained in roaima’s answer; if you’re curious about that, feel free to [edit] your question to ask about it and I’ll re-open. – Stephen Kitt Dec 03 '22 at 17:50

1 Answers1

1

I wrote a script in the rc.local file using the sudo command

You don't need to use sudo, as rc.local is executed as root anyway.

Nevertheless, let's look at what's going on here.

root       430     1  0 12월02 ?      00:00:00 sudo python3 process.py
root       511   423  0 12월02 ?      00:04:54 python3 process.py

Process 430 is the one invoked from rc.local where you use sudo. Process 511 is puzzling me a little, though; I would have expected its parent to be 430 but it seems to be from something even earlier. It would help to see the exact code section in your rc.local. It's the command actually invoked from sudo. When the process ends, the sudo will complete and it will also exit.

roaima
  • 107,089
  • 14
  • 139
  • 261