kiranmadansar
Posts: 2
Joined: Tue Jul 26, 2016 1:09 pm

Not running a script

Wed Aug 17, 2016 9:50 am

Hello,

I have two python scripts.
1) reads the data from SQLite database
2) writes to database using a threading module and queue

I have put these in the rc.local and are executing fine on reboot. But, if I unplug the power suddenly and re-plug it, only reading script is executing. Is it because of the thread and queue (both are not terminating properly due to power off) that i'm using?

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Not running a script

Wed Aug 17, 2016 7:44 pm

I try to avoid using rc.local for boot scripts. Once upon a time I used them exclusively, then I learned cron and life was better.
Try moving your scripts to /home/pi and adding the following line to crontab (type "crontab -e" to get to the editor and see my sources below for a more in depth tutorial).

Code: Select all

@reboot  python /home/pi/read.py &
@reboot  python /home/pi/write.py &
sources: http://www.cyberciti.biz/faq/linux-exec ... em-reboot/
http://www.raspberrypi-spy.co.uk/2013/0 ... sing-cron/

User avatar
DougieLawson
Posts: 39837
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Not running a script

Thu Aug 18, 2016 12:00 am

Better than crontab -e is /etc/cron.d/somefilenamehere create a unique file in that directory for each thing you want cron to launch.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

User avatar
thagrol
Posts: 3532
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Not running a script

Thu Aug 18, 2016 6:12 pm

Try changing the startup command (regardless of whether it's in rc.local, crontab, etc) to something like this:

Code: Select all

/path/to/writer.py >/tmp/writer.log 2>&1 &
This should capture any output and error messages in /tmp/writer.log.
Arguing with strangers on the internet since 1993.

Return to “General discussion”