Go to advanced search

by komarek
Sat Jul 01, 2017 6:55 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

You can check the difference in the environment by modifying the analitico.sh to contain: #!/bin/bash LOG_FILE="/home/pi/Documents/PY/analitico.log" #echo "Hello from shell" >> $LOG_FILE env >> $LOG_FILE /usr/bin/python3 /home/pi/Documents/PY/analitico.py &>> $LOG_FILE and compare the output of "en...
by komarek
Sat Jul 01, 2017 4:23 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

tpylkko wrote:Do you mean that you don't know what a user service is?

See this for example, then:
https://wiki.archlinux.org/index.php/Systemd/User
i never used that
by komarek
Sat Jul 01, 2017 2:23 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

My bet is that your script requires session data, which is not available for a systemd system service. Printing to Log or launching a file does not require a user session, but maybe the auth stuff in your Python does? Have you tried a user service instead of the system one? IIRC, this changed in so...
by komarek
Sat Jul 01, 2017 2:23 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

I notice the problem script is using MQTT. I had similar issues running a script using MQTT from cron upon reboot. The fix ended up bring to put a 60 second sleep inside the script before the script does anything (ie after the imports). My guess is it was trying to use something not yet available a...
by komarek
Sat Jul 01, 2017 2:20 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

NotRequired wrote:Looks right, are there any indications of errors in analitico.log or syslog (command above)?
nothing at all
by komarek
Sat Jul 01, 2017 1:27 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

I'm launching 2-3 python scripts with systemd - no problem at all, so I'm wondering... Did you try to modify the first line of analitico.py to be "#!/usr/bin/env python3"? Please post contents of analitico.sh (if still used) and analitico.service.. yes i changed the first line of analitico.py this ...
by komarek
Sat Jul 01, 2017 12:42 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Ferdinand wrote:The execute bit is not set
chmod 777 <your file>
yep you're right
anyway... now it's working.... with /home/pi/Documents/PY/analitico.py
but if i run the daemon with systemd the script still doesnt work
by komarek
Sat Jul 01, 2017 11:21 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Ferdinand wrote:Your are not the owner of that file
sudo chown pi <your file>
yes it does:
-rw-r--r-- 1 pi pi 4580 lug 1 11:00 /home/pi/Documents/PY/analitico.py

but when i try to run it as you said... i have the same error:
-bash: /home/pi/Documents/PY/analitico.py: Permission denied
by komarek
Sat Jul 01, 2017 10:36 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

What happens when you launch the PY script as an executable, without adding it as an argument to python3 (command: /home/pi/Documents/PY/analitico.py)? Does the script still launches properly? If not the issue might be caused by the shebang notation as pointed out by "Ferdinand". if i run this comm...
by komarek
Sat Jul 01, 2017 8:59 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Take a look at the first line in analytici.py and fanspeed.py One file is referring to python 2 the other file is referring to python 3. Perhaps this is the problem. I cannot test at the moment. it doesnt make sense if i run the script analitico.py or even the bash script analitico.sh out of the sy...
by komarek
Sat Jul 01, 2017 7:01 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Perhaps you may post fanspeed.py too. Then you can compare both files. ok but i can't see the point #!/usr/bin/env python3 import os import time from time import sleep import signal import sys import RPi.GPIO as GPIO fanPin = 4 maxTMP = 48 def setup(): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM)...
by komarek
Sat Jul 01, 2017 12:18 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Nice, then we know that the shell script works, but the python script is not invoked at all. When you run command "whereis python3" a list of paths should appear, the first should be something like "/usr/bin/python3", right? Please try to enter the full path to python3 into the shell script (you ca...
by komarek
Fri Jun 30, 2017 5:36 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

everything works... the shell is been loaded but
when it cast the script something goes wrong... and there's no signs of where the issue is
by komarek
Fri Jun 30, 2017 5:30 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Please try to change your "analitico.sh" to contain: And reboot with the analitico service enabled. When booted try to execute command "cat /home/pi/analitico.log" - what is the output? the log file just says: hello from shell and the service status is: Loaded: loaded (/lib/systemd/system/analitico...
by komarek
Fri Jun 30, 2017 5:03 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

i will never find a solution for this crap
by komarek
Fri Jun 30, 2017 5:02 pm
Forum: General discussion
Topic: how to trigger raspi by the doorbell
Replies: 27
Views: 6813

Re: how to trigger raspi by the doorbell

wow thank you guys for all these info.
anyway i will experiment on the bradboard before i connect the Rpi

thank you
by komarek
Fri Jun 30, 2017 3:02 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

looks like something wrong in this file:

Code: Select all

[Unit]
Description=Servizio Gestione Google Analytics su MQTT
After=multi-user.target
Wants=network.target network-online.target

[Service]
Type=idle
User=pi
ExecStart=/home/pi/Documents/SH/analitico.sh

[Install]
WantedBy=multi-user.target

by komarek
Fri Jun 30, 2017 3:00 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

obviously if i run /home/pi/Documents/SH/analitico.sh manually
it works well
by komarek
Fri Jun 30, 2017 2:56 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Did you remember to set executable bit for the *.sh? now i've set the chmode to 777 and gave me denied permission for: /dev/shm/analitico.log then i got rid of "/dev/shm/analitico.log" and when i do sudo service analitico status i have this: Loaded: loaded (/lib/systemd/system/analitico.service; en...
by komarek
Fri Jun 30, 2017 2:48 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

NotRequired wrote:Did you remember to set executable bit for the *.sh?
yes
and then i tried to chmod 644 also

same error
by komarek
Fri Jun 30, 2017 2:32 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

no way

Loaded: loaded (/lib/systemd/system/analitico.service; enabled)
Active: failed (Result: exit-code) since ven 2017-06-30 16:26:43 CEST; 5min ago
Process: 2018 ExecStart=/home/pi/Documents/SH/analitico.sh (code=exited, status=203/EXEC)
Main PID: 2018 (code=exited, status=203/EXEC)
by komarek
Fri Jun 30, 2017 1:27 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

NotRequired wrote:Does the output from the py script give you any clue?
no clue
the only thing i can say... that if i run the script manually: python3 /home/pi/Documents/analitico.py
it works like charm
by komarek
Fri Jun 30, 2017 1:08 pm
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

This is not strange, systemd commands does not run in a shell and the redirect operator ">" is handled by the shell (BASH). If you want to use ">" you should put the command line in a shell script and execute that instead. Also, since your py uses network you might want to change your service to in...
by komarek
Fri Jun 30, 2017 12:00 pm
Forum: General discussion
Topic: how to trigger raspi by the doorbell
Replies: 27
Views: 6813

Re: how to trigger raspi by the doorbell

yes... the circuit would look something like this one.
the voltage between A and B i guess it will be the 12V of the chime
by komarek
Fri Jun 30, 2017 11:21 am
Forum: General discussion
Topic: python script at startup
Replies: 81
Views: 10504

Re: python script at startup

Another tip: Do not use rc.local to start long running background services with dependencies. Use systemd and specify the dependencies instead - this will ensure that the script is invoked after the dependencies are ready to use :) well i tried with systemd now this is my analitico.service file: [U...

Go to advanced search