Reputation: 89
apologies for the long question, but I need to be as specific as possible.
I am creating a project that allows me to control the functionality of a camera with a remote control. This project is run from a Python program, and pipes its output into another program, called chdkptp (which is the program that allows me to control the camera). A little bit ago I was trying to figure out how to get this project started on bootup (so I could plug my Raspberry Pi in, and have everything working without the need of the desktop). I tried a couple different things (such as adding the command I wanted to the rc.local file, etc), but ended up adding an autostart to
~/.config/autostart
and this is what's inside of the file I made:
[Desktop Entry]
Encoding=UTF-8
Name=Terminal autostart
Comment=Start a terminal and boot remote_function.py piped into chdkptp.sh
Exec=/usr/bin/lxterm -e 'cd chdkptp-r735 && ./remote_function.py|./chdkptp.sh'
Basically this opens lxterm and executes the command that I need to start up my python program that pipes its output to chdkptp, and this works.
But my question is this: I believe I may have accidentally started my Python program in a different location while trying to figure out what I needed to do because my python program boots up twice. I know this because I have an LED flash once when the program is up and running, but it flashes twice and I cannot figure out where else I had my program boot up. How do I go about figuring this out?
I may already have an answer, but don't know what it means... I typed this command suggested by someone:
ps -ax | grep 'remote_function.py'
and got this response:
875 ? S 0:00 xterm -class UXTerm -title uxterm -u8 -e cd chdkptp-r735 && ./remote_function.py|./chdkptp.sh
1026 pts/0 Ss+ 0:00 bash -c cd chdkptp-r735 && ./remote_function.py|./chdkptp.sh
1028 pts/0 S+ 0:00 python ./remote_function.py
2169 pts/1 S+ 0:00 grep --color=auto remote_function.py
Is this the answer? If so, what exactly does this mean? Does it have anything to do with the shebang at the beginning of my python program? I am a a newbie when it comes to that. If that is not the answer, how to I go about finding where else my program is starting on bootup?
The shebang is this, for reference:
#!/usr/bin/env python
Upvotes: 3
Views: 514
Reputation: 89
[SOLVED]
I figured it out.
https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=59285
I have been connecting to my raspberry pi with VNC, and I had an autostart command along with my remote_python autostart to start the VNC server so I could remote in to my pi without needing a monitor. Turns out there is some sort of bug with the VNC Server that starts things up twice. Of course. I am using an x11 VNC server instead and now things are only booting up once :)
Upvotes: 1
Reputation: 3158
You do, in fact, have two processes running your python script.
Finding out what started the second may not be very fun, but since you can see that the second one is started with python ./remote_function.py
then you have two clues:
First, in order for that^ to work, it would have to be in the same folder as your remote_function.py
- perhaps you remember tinkering with something that started it by itself in that^ way?
Second, you may be able to find the location of the file that holds that^ via sudo grep 'python ./remote_function.py' ~
- but since it calls it with ./
- it should be pretty plainly obvious (unless you have copies of that file scattered about - which may be the case.
Upvotes: 0