Skip to content

Automate using Crontab ‐ Linux

Benny Thadikaran edited this page Aug 21, 2023 · 2 revisions

1. Get Python3 executable path

Open your terminal, type which python3 and press Enter. Copy the output to use later.

2. Edit your crontab

Type crontab -e and press Enter. It will open crontab in your preferred editor.

Add the below line to your crontab. Replace <python3-path> with the path you copied in Step 1. Replace <init.py-path> with the full path to init.py in your project folder.

15 19 * * 1-5 <python3-path> <init.py-path> >> ~/Desktop/cron.log 2>&1

This will execute python3 init.py Monday to Friday at 7:15 pm and log any output to ~/Desktop/cron.log.

Save the file and exit.

NSE Daily reports get updated after 7 pm, so preferably schedule script execution post 7 pm only.