Go to advanced search

by zara2355
Mon Dec 19, 2016 8:12 pm
Forum: Troubleshooting
Topic: requests_oauthlib Python 3 error
Replies: 6
Views: 1950

requests_oauthlib Python 3 error

... This is my very first go at using Raspberry Pi and I ... to have this autorun at startup, or start at reboot ... the terminal to using Python 3 (IDLE). Using the terminal, ... open Python 3 (IDLE) and "Run Module", it works! Great...... ... to make this python script via "sudo nano .bashrc" ...
by Ferdinand
Fri Dec 09, 2016 12:51 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

frankenberry wrote: I now have a working script. Although, I do not understand why it works...
NCLAB has a very good ebook "Introduction to Python Programming"
and re(read) the excellent cronHOWTO post of RaTTus.
by frankenberry
Fri Dec 09, 2016 2:23 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... help and suggestions! I now have a working script. Although, I do not understand why it works... ... worked fine. I then modified the script to run my script outputting to a different filename, ... crontab with "sudo crontab -e", having "root python" in the crontab command and/or permission ...
by frankenberry
Fri Dec 09, 2016 2:11 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... on one of my Pi's this is how I did it. First off I changed your short python program so that it writes the required output driect to the file from ... lite. THANK YOU!!! Followed your steps, it worked. Modified original script and it worked with my python script.
by pcmanbob
Thu Dec 08, 2016 5:14 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... it seems you are still having problems So I set about doing the job myself on one of my Pi's this is how I did it. First off I changed your short python program so that it writes the required output driect to the file from withing the program. #!/usr/bin/python import datetime now = datetime.datetime.now() ...
by RaTTuS
Thu Dec 08, 2016 3:27 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Ferdinand wrote:
RaTTuS wrote: crontab -e
* */4 * * * /path/to/python /path/to/script arguments >/tmp/redirection.ouput.file
It's 0 */4 * * * /path/to ...
Otherwise 60 extra lines will be made in an outputfile.
I tested it.
yes my mistake - or any number from 0-59
by Ferdinand
Thu Dec 08, 2016 1:01 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

RaTTuS wrote: crontab -e
* */4 * * * /path/to/python /path/to/script arguments >/tmp/redirection.ouput.file
It's 0 */4 * * * /path/to ...
Otherwise 60 extra lines will be made in an outputfile.
I tested it.
by RaTTuS
Thu Dec 08, 2016 12:44 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

I'm running Jessie on a RPi1B. I would like to run a python script every 4 hours. Crontab seems ... reason or another. Requirements: At boot, run python script at startup in background. Thanks! crontab ...
by Martin Frezman
Thu Dec 08, 2016 12:33 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Somebody needs to keep their emotions in check.

And it's not me.

Edit: We really shouldn't be having this conversation here. Anything further should be in PM.
by DougieLawson
Thu Dec 08, 2016 12:19 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Martin Frezman wrote:More cruelty to newbies.
Please either add something constructive to this discussion or keep quiet.
by Martin Frezman
Thu Dec 08, 2016 12:15 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

More cruelty to newbies.
by RaTTuS
Thu Dec 08, 2016 11:05 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... what it says in the file full paths to everything including in your scripts - never use short cuts it will bite you m h (day of month) (month) ... cron has a restricted environment learn it and use it if you are using python tehn shebang [#!] your script file and let the system work it out ...
by Martin Frezman
Thu Dec 08, 2016 10:46 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

@reboot /usr/bin/python /home/pi/CronJobs/testPython.py >> /home/pi/time.txt 0 */4 * * * /usr/bin/python /home/pi/CronJobs/testPython.py >> /home/pi/time.txt As I said, all that extra verbiage - all that /usr/bin/ stuff and all that ...
by Ferdinand
Thu Dec 08, 2016 7:11 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Hi frankenberry, Use crontab -e to edit your pi crontab: @reboot /usr/bin/python /home/pi/CronJobs/testPython.py >> /home/pi/time.txt 0 */4 * * * /usr/bin/python /home/pi/CronJobs/testPython.py >> /home/pi/time.txt This will add/create a line in time.txt directly ...
by frankenberry
Thu Dec 08, 2016 5:18 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... is still not working. First, update script to output to a file, change format ... terminal: pi@raspberrypi:~ $ sudo python CronJobs/testPython.py>>CronOutput/Output-1.txt ... this file to introduce tasks to be run by cron. # # Each task to run has to ...
by frankenberry
Thu Dec 08, 2016 4:35 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

rpdom wrote:cron does at least recognise the ~ shortcut for the home directory, so you can use

Code: Select all

* * * * * /usr/bin/python ~/CronJobs/testPython.py
(You don't need a & on the end of a crontab entry, it's pointless)
Thanks. I removed '&' and will keep the './' shorthand in mind for future script.
by frankenberry
Thu Dec 08, 2016 4:33 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

I had same sort of problem after update to Jessie. I cannot check for the moment but if i remember correctly you have to now put full path in for Python so /1 * * * * root python /home/pi/CronJobs/testPython.py & should be /1 * * * * root /usr/sbin/python /home/pi/CronJobs/testPython.py & TerryR ...
by frankenberry
Thu Dec 08, 2016 4:33 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... I think you may not be setting your cron job time correctly. so to run a job every minute you would use * * * * * python /home/pi/CronJobs/testPython.py & to run a job every 5 minutes you would use */5 * * ...
by frankenberry
Thu Dec 08, 2016 4:30 am
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... cron, it should certainly be running on your system. What makes you think it doesn't? What does your script do? I'm also a bit confused: Do you want to run it at startup or every 4 hours? Currently my script ...
by DougieLawson
Wed Dec 07, 2016 9:23 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Since most of the local code I install goes in /usr/local/bin then I do have to have the full path. root's cron runs with HOME=/root LOGNAME=root PATH=/usr/bin:/bin LANG=en_GB.UTF-8 SHELL=/bin/sh PWD=/root pi's cron runs with HOME=/home/pi LOGNAME=pi PATH=/usr/bin:/bin LANG=en_GB.UTF-8 SHELL=/bin/sh...
by dasmanul
Wed Dec 07, 2016 9:19 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

Also, note that in the crontab posted, PATH is explicitly set.
by Martin Frezman
Wed Dec 07, 2016 8:59 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

... not: 1) /usr/bin is on PATH, so python (and just about everything else) ... it. 2) The current directory on startup of a cron job is the user's ... So, no need to full path it to run something in your home directory. ... to do: /usr/bin/python /home/pi/myscript.py but you do have to do: ./myscript.py ...
by rpdom
Wed Dec 07, 2016 8:52 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

cron does at least recognise the ~ shortcut for the home directory, so you can use

Code: Select all

* * * * * /usr/bin/python ~/CronJobs/testPython.py
(You don't need a & on the end of a crontab entry, it's pointless)
by DougieLawson
Wed Dec 07, 2016 7:23 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

That's always true with crontab. Cron, by default, runs with a very restricted environment.
by thegnnu
Wed Dec 07, 2016 6:38 pm
Forum: Python
Topic: Run Python Script at Startup
Replies: 40
Views: 8597

Re: Run Python Script at Startup

I had same sort of problem after update to Jessie. I cannot check for the moment but if i remember correctly you have to now put full path in for Python so
/1 * * * * root python /home/pi/CronJobs/testPython.py &
should be
/1 * * * * root /usr/sbin/python /home/pi/CronJobs/testPython.py &

TerryR

Go to advanced search