title: How to run a python file using cron jobs
body: <p>Hi I have created a python file for example as <code>file_example.py</code></p>
  
  <p>The file will output the sensex value</p>
  
  <p>Suppose the path of the file on linux system is <code>/Desktop/downloads/file_example.py</code></p>
  
  <p>and I normally will run the file like <code>python file_example.py</code></p>
  
  <p>But I want to set a cron job to run the python file every 2 min which is located at the above path</p>
  
  <p>Can anyone please let me know how to do this </p>
  
  <p><strong>Edited Code</strong>:</p>
  
  <p>I had edited the code and created a bash script with the name test.sh as indicated below</p>
  
  <pre><code>#!/bin/bash 
  cd /Desktop/downloads/file_example.py
  python file_example.py 2&gt;log.txt 
  </code></pre>
  
  <p>When I run the above file, the following error is displayed:</p>
  
  <pre><code>sh-4.2$ python test.sh
    File "test.sh", line 3
      python test.py 2&gt;log.txt 
                ^
  SyntaxError: invalid syntax
  </code></pre>