gproduct
Posts: 59
Joined: Tue Aug 11, 2015 1:27 pm

Run Raspberry Pi even when not connected

Tue Aug 25, 2015 11:33 am

Hello!
I've been working on my raspberry pi and I want it to run 24/7 (a main.py function)
The file is in a while loop
What do I do so it can run the function all the time even when im not connected to it via ssh?

Thx
(i tried screen but I don't think it's working)
:cry:

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Run Raspberry Pi even when not connected

Tue Aug 25, 2015 11:43 am

screen does work. I use it all the time. I have a screen session running on one of my Raspis right now.

Connect with ssh.
Start screen
Run command
Exit the screen session with Ctrl-A then "d", or end the ssh session.
Log out.

Log back in.
Reconnect to the screen session with "screen -r" or "screen -r ID"

List running screens: screen -ls

gproduct
Posts: 59
Joined: Tue Aug 11, 2015 1:27 pm

Re: Run Raspberry Pi even when not connected

Tue Aug 25, 2015 11:47 am

Yea I know it works, but I don;t know how to use it.
I'm gonna check

gproduct
Posts: 59
Joined: Tue Aug 11, 2015 1:27 pm

Re: Run Raspberry Pi even when not connected

Tue Aug 25, 2015 11:51 am

Thx man it's working :D :o :o ;) ;) :D :D :lol:

User avatar
Paeryn
Posts: 2966
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Run Raspberry Pi even when not connected

Tue Aug 25, 2015 11:55 am

You can also use nohup and run it in the background

Code: Select all

nohup python main.py &
She who travels light — forgot something.

Return to “General discussion”