Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5175

Python • Program stops after initiated with CRONTAB - runs fine directly from mu

$
0
0
Summary of issue:
1) Program runs fine when invoked with mu and running. However, when automatically initiated via crontab, program halts with no errors.

Hardware/Software Configuration:
Raspberry Pi 4
Using Mu for python development
Latest firmware/software updates


Snippet of program:

# Load library routines, docs at: https://gpiozero.readthedocs.io/en/stable/
import gpiozero
from time import sleep
import datetime
import logging
import smtplib
import os

def eMail(message, subject): # using gmail
print("@93.. Start of eMail")
from_address="ChristmasTreeWatering@northpole.com"
to_address=ini_status_email_to
print("@96...about to open object with smtplib")
mymail=smtplib.SMTP('smtp.gmail.com',587)
print("@98 ... starting handshake...") # THIS LINE NEVER EXECUTES UNDER CRONTAB


Line added to crontab:
@reboot python3 /home/pi/mu_code/Christmas_Tree_Watering_7.py >> tafout.txt&

Output from crontab (tafout.txt) after reboot
in INIRead, ini_status_email_detail str= 4
@151 Write initial startup to log file
@153 ...
@155
@157..
@93.. Start of eMail
@96...about to open object with smtplib
<<NOTHING ELSE …. SHOULD SEE @98 … starting handshake >>

Statistics: Posted by TimFino — Fri Dec 22, 2023 11:01 pm



Viewing all articles
Browse latest Browse all 5175

Trending Articles