T3rr0rByte13
Posts: 8
Joined: Sun Jan 21, 2018 9:03 pm

Make Python Script Show on Startup

Sun May 10, 2020 1:46 am

Hi,
I have a python script, that runs on startup using Crontab, I think it is running fine, however how do I get the script to show the output of the python script in a console window rather then it running in the background. My Launcher script looks like the following

Code: Select all

cd /home/pi/Desktop
echo Starting...
sudo python Stronghold_CMD_Robotic_Arm.py
cd /

GlowInTheDark
Posts: 594
Joined: Sat Nov 09, 2019 12:14 pm

Re: Make Python Script Show on Startup

Sun May 10, 2020 6:18 am

Run it in a console window, like you're supposed to.

The problem you are experiencing is is one of the many reasons why running things with cron is a bad idea (unless/until you're fully familiar with how cron works and its limitations and "features").

Yes, there are ways to make stuff run in a console window (I assume by that you mean, a terminal window on the desktop, not an actual virtual console), but the exact details of how to do that are beyond the scope of this post.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Make Python Script Show on Startup

Sun May 10, 2020 11:02 am

If you want to run your program in the terminal on the desktop at pi boot then you need to use the GUI autostart file.

to edit the file

Code: Select all

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
then add this line to the end of existing lines

Code: Select all

@lxterminal -e python /home/pi/Desktop/Stronghold_CMD_Robotic_Arm.py
note this is running your code as python 2 , if you want python 3 then you need to use python3 in place of python.

save and exit the file .

you program should run on booting the pi and once the GUI has loaded.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jsquaredz
Posts: 2
Joined: Sun Mar 15, 2015 7:10 pm

Re: Make Python Script Show on Startup

Sun May 10, 2020 10:30 pm

If you just want to see the output you can append it to a file.

* * * * * command >> logfile.txt

then any output that would have come to the console is directed into the end of that file.

Return to “Raspberry Pi OS”