yowsup program in python not always running on raspian boot - python

finally got Yowsup working on my Pi and it works fantastic. The problem I´m facing now is the following:
I run a command line to get Yowsup working:
sudo python /home/pi/yowsup/run.py
So I put this same line inside rc.local so that the program starts when raspian boots. The problem is that this solution seems to work randomly and I cant figure out the reason.
I also added the following line to crontab:
#reboot sudo python /home/pi/yowsup/run.py
Still, sometimes it starts and sometimes it does not.
Any ideas? The problem gets specially annoying when booting my Pi headless, because I have to log in another machine to connect to my Pi and run the program remotely.

Related

How to start a python script after booting in Raspbian?

I made an app in Thonny that when I run it, shows a camera connected to RPI and shows the image in an interface. You can also use the keyboard to do some things in the interface, take photos, etc.
I always execute it using thonny (run button), but now, I am trying to autostart the program in python when Raspbian ends its starting (after a shutdown or reboot).
I tried to do it in 3 ways:
autostart
lxde-pi/autostart
crontab
But it doesn't work. It starts Raspbian, but nothing more. Any ideas or code to do it?
Thanks a lot.
This might be a bit late for #mash_10, but for anyone else who lands here my solution that auto fires a bash script on the home folder. To add new automatic startups I just add code to my personal bash script. This works on Buster rpi.
Details are in my answer here How to automatically launch python file once GUI has loaded on Raspbian Pixel

Start python script on startup - python script runs after login on raspberry pi?

I would like to run a python script directly on startup of the raspberry pi. I can execute the script by calling /home/pi/scripts/script.py. Now I tried to add the script to /etc/rc.local or /etc/profile or start it with systemd. For all cases the script is only executed after a connection to the pi via SSH and a login to the pi.
Therefore I would like to know who I could execute the script on boot (startup) without having to do a login?
You were on the right track with systemd and unit files.
First read this:
[https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files]
You probably used multi-user.target as wanted-by but that is too late.
You could use
sudo systemd-analyze critical-chain
to see which .targets might be better for your need.For example basic.target looks good.
You can of course also state in the unit file explicitly that your unit (.service) needs to be loaded before for example ifup#eth0.service
Use sudo systemctl list-units or sudo systemctl list-unit-files to see everything that in this respect is going on.

Run python script right after RPi boot

I'm relatively new to raspberry pi (5 days using it) and I've just finished to run my python script succesfully (called dogcare.py). Now I'm trying to execute this script right after my raspberry is turned on. I've been doing some research and I find different ways to do it:
using /etc/profile
using /etc/rc.local
using crontab
using /etc/init.d
using systemd
But none of these ways are working for me.
Setup enviroment:
Hardware: RaspberryPi 2 Model B
Software: Raspbian or NOOBs (not sure)
Context:
Since for my project I need to run meet.jit.si, I followed this guide http://www.instructables.com/id/Video-Calling-on-Raspberry-Pi-3/?ALLSTEPS and It has a step where sets chromium website to start right after RPi is turned on. (Currently this is working fine)
My python script is using request library in order to use HTTP GET with an external website application I've been working on.
Main problem:
I need to run both events: chromium website with meet.jit.si and my python script when my raspberry is turned on.
Current situation: chromium website is running after my RPi is turned on but my script doesn't.
I'd appreciate any help !
I have done a similar thing with my Raspi 2 as well which involved sending myself an email with the ip address of the pi so I could easily ssh/vnc to it.
My steps involved making a shell script which ran the python program.
#!/bin/sh
cd pythonfiledirectory
sudo python pythonfile.py
cd /
Then I made it executable with the following command:
chmod 777 file.sh
Now edit your crontab to run the file on startup.
In your terminal, type:
sudo crontab -e
Inside of the crontab write:
#reboot sh file.sh
You could add a log file if you wanted to debug and see why it's not working by making a log directory and changing the text you wrote in the crontab to:
#reboot sh file.sh >/logdirectoy/ 2>&1
This is what made it work for me and if it doesn't work try and make sure you can run your .sh file and try the crontab with some other files to debug the problem.

Raspberry Pi - Run Python script at Startup using "screen" session

I have really tried looking around but all the examples I find do not work for me.
I have a python script in a Raspberry Pi that starts using CRON....all good!
I would like to be able to debug the ouput that the script prints in screen from time to time so the "screen" command needs to be used to create a session and ensure that I can login and logoff using putty as needed.
I also add the "&" so it will run in background.
So currently I did:
1) Open cron
sudo crontab -e
2) Add the following line
#reboot python /home/pi/python/monitor.py &
This works correctly, I just need to know how to make a "screen" session open before launching the python script.
Thank you very much for your help!

Run terminal command as startup reacts different from manually (linux raspberry pi)

Here's a short description of what I have:
I have to raspberry pi's in a local net work. I one of them I have a .py script named watchdog.py that starts a stream and then uses a sshpass command to the other pi to display the video stream.It also has some signaling LEDs a some push buttons for control
the problem is:
If I open a terminal and run the watchdog.py script in the GUI everything runs as it should be. So I thought of running it as a service as boot and installed upstart and made it run as a service (successfully I think). The thing is. If I boot the pi and then press the button to start the streams,they wont play on the other Pi, the LEDs ligh up and all the buttons work. And even the CPU load behaves the same way, but i still don't video nor audio. I have thought of trying automatically open a terminal (LXterminal) widow and run the python scrip on that window. but I didn't want the streaming raspberry pi also booting into gui (tough I guess I would mind if that makes the whole thing work).This little thing i making the whole project useless.
What are you using to play the streams? Depending on how you boot up the second Raspberry it might not have started some daemons for audio/video playback?!
You should (if you're not already doing) write a log (import logging ;)) and write a logfile which you can track for errors.
answer moved from OP's question itself:
I found a way that seems to work so far. instead of running the python script as a service I tried running it as cron job at reboot, and it worked. now it all works straight from reboot and I have Audio and video.

Categories

Resources