mugurdi
Posts: 68
Joined: Tue Oct 14, 2014 3:49 am

Know how a process has been started

Tue Jul 24, 2018 4:05 am

Hello,
I have a python program weather.py that I want to run at the beginning, it collects the weather data from some sensors.

In /etc/rc.local I wrote the line:
sudo python3 /home/pi/weather/weather.py &

When I look at the processes, I see two processes:

pi @ raspberrypi: ~ $ ps -ef | grep weather
root 589 1 0 05:48? 00:00:00 sudo python3 /home/pi/weather/weather.py
root 605 589 66 05:48? 00:01:46 python3 /home/pi/weather/weather.py
pi 1114 1103 0 05:51 pts / 0 00:00:00 grep --color = auto weather

How can I know where the second one comes from?

jerrm
Posts: 202
Joined: Wed May 02, 2018 7:35 pm

Re: Know how a process has been started

Tue Jul 24, 2018 4:27 am

PID 589 is execution of sudo
PID 605 is execution of python by sudo (PPID is 589)

Anything launched from rc.local is already running as root. sudo is not needed (unless you want to run as a non-root user).

mugurdi
Posts: 68
Joined: Tue Oct 14, 2014 3:49 am

Re: Know how a process has been started

Wed Jul 25, 2018 4:31 am

Thanks!

Return to “Beginners”