hasanoa
Posts: 13
Joined: Mon Jan 12, 2015 12:51 pm

problem, because of multiple running of python codes

Wed Apr 20, 2016 7:04 am

Hi everyone,

I added followed lines to end of /etc/profile file. (adding .bashrc causes the same result)

Code: Select all

sudo python /home/pi/shutdown.py &
sudo python /home/pi/output.py &
After start up, I found 6 process for shutdown.py and 6 process for output.py as attached img.

Is it possible to solve this problem?

Thank you
Attachments
has.gif
img
has.gif (29.56 KiB) Viewed 680 times

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: problem, because of multiple running of python codes

Wed Apr 20, 2016 9:29 am

/etc/profile is used for every login, so if multiple users log in it will be started multiple times.

You could add it to /etc/rc.local or use a system service to start the scripts.
For Jessie see e.g. http://www.raspberrypi-spy.co.uk/2015/1 ... g-systemd/

hasanoa
Posts: 13
Joined: Mon Jan 12, 2015 12:51 pm

Re: problem, because of multiple running of python codes

Wed Apr 20, 2016 10:18 am

Hi DirkS,

- "rc.local" option did not solve my problem. It did start nothing.
- "system service" option fixed the problem.

Thank you for your help

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: problem, because of multiple running of python codes

Wed Apr 20, 2016 10:30 am

Good. I think using a system service is the better solution of the two.
hasanoa wrote:- "rc.local" option did not solve my problem. It did start nothing.
Should have worked. I forgot to mention that you need to put your commands before the line 'exit 0'

hasanoa
Posts: 13
Joined: Mon Jan 12, 2015 12:51 pm

Re: problem, because of multiple running of python codes

Wed Apr 20, 2016 11:12 am

It's ok, system services are working very well. I configured 2 different service for 2 different python...

Thank you again...

:)

Return to “Beginners”