Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ekapujiw2002/b0575a9448947925eb885d1aa7024aae to your computer and use it in GitHub Desktop.
Save ekapujiw2002/b0575a9448947925eb885d1aa7024aae to your computer and use it in GitHub Desktop.
How to create a systemd service for python script with virtualenv
[Unit]
Description=Some description
After=network.target
[Service]
Type=simple
User=user
WorkingDirectory=/home/user/somedir
Environment=PYTHONPATH=/home/user/somedir
ExecStart=/home/user/venv/bin/python script.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment