Skip to content

Instantly share code, notes, and snippets.

@William-Lake
Created March 29, 2019 13:06
Show Gist options
  • Save William-Lake/958a414a876cc2bd483958a041b84b6d to your computer and use it in GitHub Desktop.
Save William-Lake/958a414a876cc2bd483958a041b84b6d to your computer and use it in GitHub Desktop.
Running Python unittests with conda environment via cronjob

Instructions

  • Create crontab string via crontab.guru
  • Create a bash script to run your unittests

E.g.

#!/bin/bash

# Not certain this is necessary...
cd /path/to/your/module

# Assumes your unittests are in a directory named tests/ in your module's directory.
# tests.test_modulename == <modules's test directory>.<name of test file to run without the .py extension>
source /path/to/miniconda/bin/activate /path/to/miniconda/envs/module/env && python -m unittest tests.test_modulename &> /path/to/module/output.log
  • Create your crontab entry via crontab -e:

* * * * * bash /path/to/your/script/run_tests.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment