title: How to schedule a job using python and crontab?
body: <p>I would like to send an automated mail using python, django and crontab. So I did the following things.</p>
  
  <p>Created a cron_tab.py(which is inside the folder home/myhome/django/myapp/registration/cron_tab.py) which looks like below: </p>
  
  <pre><code>from django.core.mail import send_mail, EmailMessage,EmailMultiAlternatives
  
  subject, from_email, to = 'hello', 'testmailing@gmail.com', 'robert@gmail.com'
  text_content = 'This is an important message.'
  html_content = '&lt;p&gt;This is an &lt;strong&gt;important&lt;/strong&gt; message.&lt;/p&gt;'
  msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
  msg.attach_alternative(html_content, "text/html")
  msg.send()
  </code></pre>
  
  <p>And using terminal I entered in to crontab by issuing the below command</p>
  
  <pre><code>crontab -e
  </code></pre>
  
  <p>I scheduled the task like </p>
  
  <pre><code>* 1 * * *  /home/myhome/django/myapp/registration/cron_tab.py
  </code></pre>
  
  <p>But I didn't mail receive. What am I doing wrong? Please Somebody help me. After changing the file mode I get the following error and pasted the traceback</p>
  
  <pre><code> myhome@myhome:~/django/myapp/registration$ ./cron_tab.py
   from: can't read /var/mail/django.core.mail
   ./cron_tab.py: line 3: subject: command not found
   ./cron_tab.py: line 4: from_email: command not found
   ./cron_tab.py: line 5: to: command not found
   ./cron_tab.py: line 6: text_content: command not found
   ./cron_tab.py: line 7: html_content: command not found
   ./cron_tab.py: line 8: syntax error near unexpected token `('
   ./cron_tab.py: line 8: `msg = EmailMultiAlternatives(subject, text_content, from_email,
   [to])'
  </code></pre>