Skip to content

Instantly share code, notes, and snippets.

@liquidgenius
Created July 23, 2021 16:10
Show Gist options
  • Save liquidgenius/c49d960772df0181d3f3fd33c3378328 to your computer and use it in GitHub Desktop.
Save liquidgenius/c49d960772df0181d3f3fd33c3378328 to your computer and use it in GitHub Desktop.
A bash shell script for launching a python script in a pipenv envelope.
#! /bin/bash
# License: MIT; https://opensource.org/licenses/MIT
# Version: 0.0.1
# Maintainer: https://gist.github.com/liquidgenius
# Given a script main.py on an ubuntu machine in /home/ubuntu/app/src directory with the interpreter
# in /home/ubuntu/app/.venv directory in project. This script, run.sh, would be placed in the
# /home/ubuntu/app directory.
# Consider adding run.sh to the Crontab to be run at 10 minute intervals with:
# crontab -e
# */10 * * * * cd /home/ubuntu/app && sudo sh run.sh
appname="app"
projdir="/home/ubuntu/$appname"
cd "$projdir/src"
PATH=/usr/local/bin:$PATH
pipenv run "$projdir/.venv/bin/python" "$projdir/src/main.py"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment