I am trying to launch a python script automatically after boot. I want to launch it in a terminal window because the program gives important feedback in the terminal.
I've researched many ways to do this including crontab, init.d, rc.local, and /etc/xdg/autostart/myscript.desktop.
When I've tested my script manually, calling rc.local from the terminal works, however none of these work after booting.
I've tried many variations, the latest in crontab:
@reboot sleep 60 && xterm -hold -e sudo python /home/pi/newcode/newcode/boot-test.py
Other variations I tried include (calling my python script from a shell script):
@reboot sleep 60 && /home/pi/bin/mount.sh && sh /home/pi/foo1.sh
and
@reboot sleep 60 && /home/pi/bin/mount.sh && sh /home/pi/foo1.sh
Update:
foo1.desktop (saved at /usr/local/bin/foo1):
[Desktop Entry]
...
Name=foo1
Exec=gksu /usr/local/bin/foo1
Terminal=false
Type=Application
Categories=GTK;System;TerminalEmulator;
foo1 (saved at /etc/xdg/autostart/foo1.desktop):
#!/bin/bash
/usr/bin/x-terminal-emulator --command="/home/pi/newcode/newcode/boot-test.py" --title="My foo1"
python script, very simple for now (saved at /home/pi/newcode/newcode/boot-test.py)
sensortype=raw_input("press enter to continue")
...
, these are only placeholder. Compare with a full blown example from your/use/share/application
directory. Double-check your saved location, your given one are exchanged to my Answer. Addpython
in front of the path to your*.py
. Compare with my Answer. Edit your Question accordingly. – stovfl