Hi I have created a python file for example as file_example.py

The file will output the sensex value

Suppose the path of the file on linux system is /Desktop/downloads/file_example.py

and I normally will run the file like python file_example.py

But I want to set a cron job to run the python file every 2 min which is located at the above path

Can anyone please let me know how to do this

Edited Code:

I had edited the code and created a bash script with the name test.sh as indicated below

#!/bin/bash 
cd /Desktop/downloads/file_example.py
python file_example.py 2>log.txt 

When I run the above file, the following error is displayed:

sh-4.2$ python test.sh
  File "test.sh", line 3
    python test.py 2>log.txt 
              ^
SyntaxError: invalid syntax
Edit
Report