I have read a few posts on this but I could not find help in them.
I have a python script that sends mail using smtplib. It works when invoked from the command line.
I have #!/usr/bin/python
as the first row and can run it both using /home/pi/ipsender.py
and python /home/pi/ipsender.py
.
My crontab is */1 * * * * /home/pi/ipsender.py
but I have also tried */1 * * * * python /home/pi/ipsender.py
and */1 * * * * /usr/bin/python /home/pi/ipsender.py
.
Doing which python
I get /usr/bin/pyhton
and running python from the command line I can import and use smtplib just fine.
In /var/log/syslog
I get:
Nov 27 22:57:01 raspberrypi /USR/SBIN/CRON[3764]: (pi) CMD (python /home/pi/ipsender.py)
Nov 27 22:57:01 raspberrypi /USR/SBIN/CRON[3763]: (CRON) info (No MTA installed, discarding output)
And I'm guessing the No MTA... is just about Cron not sending emails about what it's doing, or isn't it?
How do I run this script.
[Edit]
The permission of the script is
-rwxr-xr-x 1 pi pi 551 Nov 27 22:37 ipsender.py
[Edit2] Using the tip from D Read I'm getting the following log
starting
Traceback (most recent call last):
File "/home/pi/ipsender.py", line 7, in <module>
ifconfig_output = sp.check_output(["ifconfig", "wwan0"])
File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Suggesting to me that there is something with the path. Although in /etc/crontab
I have PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
and which ifconfig
gives /sbin/ifconfig
. So that should not be a problem right?