Scheduling Python scripts using Crontab


I’d like to use the countdown service to run a Python script to collect some data and other functions.

I understand that commands such as ‘quantrocket history collect’ can be executed by Crontab. However, for more complex workflows, I believe it’s better to use Python for this task, and reserve Crontab for pure scheduling.

Running my Python script ‘get_listings.py’ from JupyterLab works fine.

I’ve tried running the same script using Crontab with the following command:
* * * * * python /codeload/data/scripts/get_listings.py

However, I get an ImportError: ‘No module named quantrocket.master’.

I understand that when Python scripts are executed from JupyterLab the environment on my machine is /opt/conda/lib/python3.6, which also has the required site-packages /opt/conda/lib/python3.6/quantrocket/master.py, etc.

I assume when Crontab executes python that it is calling on the system’s default python, which wouldn’t include the quantrocket package.

How do I get Crontab to tell my machine to use ‘quantrocket’ Python?


Use the satellite service to run custom scripts:

* * * * * quantrocket satellite exec 'python /codeload/data/scripts/get_listings.py'