How do it do that ? Switch the user to root, than crontab -e and /usr/bin/python3 /home/osmc/switch.py as cronjob? without sudo ?
I have no idea how to do that.
The script sends a command to 433Mhz modul, and i can see if my lamp is on or off Also if i just type /usr/bin/sudo /usr/bin/python3 /home/osmc/switch.py in SSH ,it works great
I’m not at home at the moment, but i will add your lines to the cron tab.
Mar 31 19:38:01 osmc CRON[31378]: (root) CMD (logger
Cron is running)
Mar 31 19:38:01 osmc CRON[31377]:
pam_unix(cron:session): session opened for user root by
(uid=0)
Mar 31 19:38:01 osmc CRON[31379]: (root) CMD
(/usr/bin/python3 /home/osmc/switch.py)
Mar 31 19:38:01 osmc logger[31380]: Cron is running
Mar 31 19:38:01 osmc CRON[31376]:
pam_unix(cron:session): session closed for user root
Mar 31 19:38:02 osmc CRON[31377]: (CRON) info (No MTA
installed, discarding output)
Mar 31 19:38:02 osmc CRON[31377]:
pam_unix(cron:session): session closed for user root
Hi. I’ll just run through the questions listed in post #10 first.
I believe that was covered waaaay back in post #2, though the method you used in post #11 is also ok.
2 Send stdout and stderr to a log file. I’m pretty sure a quick google search would have given you the answer. There are a few ways but the one most often used is to tag this to the end of your command >>/tmp/pylog 2>&1 so the full line will now read
Two things: the file /tmp/pylog is just an arbitrarily chosen name, and could be anything you choose, and the use of double chevrons >> means that log messages will be appended to the file each time the job runs. (A single chevron overwrites the file each time.)
3 The fact that it works under SSH but not in cron suggest some environmental issue, which I hope will be clearer from the log file.
You’ve proven that cron is working, so I suggest you remove the logger message (if you haven’t done already).