Hello every body
I try to startup a python programm called "webserver.py" at reboot or startup (after halt) of the raspberry at the background
I added the next line to my crontab -e:
@reboot /usr/bin/python /home/ewh/webserver.py &
This is not working?
What am I doing wrong
Thanks
- DougieLawson
- Posts: 40594
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Programm not starting at reboot
Nobody knows.
What you need to do is add some print statements to your program and run it with
Then when it fails you'll be able to look at those logfiles to see where it failed.
What you need to do is add some print statements to your program and run it with
Code: Select all
@reboot /usr/bin/python /home/ewh/webserver.py 1>/tmp/webbything.output 2> /tmp/webbything.errors&
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Programm not starting at reboot
Thanks I will tryDougieLawson wrote:Nobody knows.
What you need to do is add some print statements to your program and run it with
Then when it fails you'll be able to look at those logfiles to see where it failed.Code: Select all
@reboot /usr/bin/python /home/ewh/webserver.py 1>/tmp/webbything.output 2> /tmp/webbything.errors&
Re: Programm not starting at reboot
It looks like that my SQL is not started yet or something like that.
The error code is:
Is there something I can do to avoid this?
The error code is:
Code: Select all
Traceback (most recent call last):
File "/home/ewh/webserver.py", line 75, in <module>
con = mdb.connect('127.0.0.1', 'pi', 'raspberry', 'tempdb');
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)")
- DougieLawson
- Posts: 40594
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Programm not starting at reboot
Addback into your /etc/network/interfaces file and reboot.
Add ablock into your code.
Code: Select all
auto lo
iface lo inet loopback
Add a
Code: Select all
try:
# ... stuff to connect to MySQL here
except:
# ... stuff to handle the exception here
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Programm not starting at reboot
Thank you
I did already make a "work around"
By calling a launcher.sh script including a sleep function at the @reboot of the crontab
It's working fine now
I did already make a "work around"
By calling a launcher.sh script including a sleep function at the @reboot of the crontab
It's working fine now