Sending email with Python script Output and using crontab to send weekly
<p>I have a Python script and I am trying to write a crontab and have the output from the Python script to be outputed to a file which then sends that output to an email address (to the body of the email not the title) that is specified. My system details and crontab entry is below:</p>

<pre><code>System details:
Python: 2.7
OSX : 10.11


host$ crontab -l
11 11 13 10 4 2016 python pythonscript.py &gt;&gt; weekly.log | mail -s weekly.log     myemail@.com
</code></pre>

<p>Although when the crontab executes, the email sends me an email message with the subject line saying "weekly.log" with no body.</p>

<p>I have also tried crontab with below settings:</p>

<pre><code>07 22 13 10 4 2016 /root/python/osversion_weekly.py | tee   /root/python/osversion`date +\%Y-\%m-\%d-\%H:\%M:\%S`-cron.log | mailx -s "OSLEVEL Report" mymail@server.com
</code></pre>

<p>Although I only get an email with Title "OSLEVEL Report" with an empty body</p>

<p>Update:
The error I seem to be getting from /var/log/cron is showing "orphan no passwd entry." Not quite sure what does means, and I havent seen any answers online to resolve this...</p>

<p>The <code>&gt;&gt;</code> makes the python output get appended to the file <code>weekly.log</code>, after that no input is pushed forward to <code>mail</code>. </p>

<p>You could remove <code>&gt;&gt; weekly.log</code> and not have a log file or use the program <code>tee</code> in the pipe. <code>tee</code> writes to standard output and a file.</p>

<p>Like this:<br>
<code>python pythonscript.py | tee -a weekly.log | mail -s weekly.log myemail@.com</code></p>

python linux osx crontab