running python scripts via crontab
davelist at mac.com
davelist at mac.com
Sat Jun 9 16:02:07 EDT 2007
On Jun 9, 2007, at 9:10 AM, Mr SZ wrote:
> Hello all,
> I wrote a simple python script to send mail via smtp to my gmail
> acc.I can run it as python /home/phil/Desktop/smtp.py but when I
> add the same to my crontab as
>
> * * * * * /usr/bin/python2.5 /home/phil/Desktop/smtp.py
>
> ,it doesn't run.I checked the process by using top command and
> python did start a thread but died soon.
>
> I need some help here.
>
> The python script uses tls-lite lib to use tls over smtp.
>
One possible issue is that I believe the crontab entries to not run
with the same environment that your normal user login does.
If you set any environment variables in your .bashrc or .bash_profile
file, try including those lines at the top of your crontab file.
Here's the first line in my crontab file (this is on OS X, but the
issue is likely the same on Linux).
PATH=/opt/local/bin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/
usr/X11R6/bin:/Users/dreed/bin
And are you really wanting to run the script every single minute (or
is that just for testing)?
Dave
More information about the Python-list
mailing list