Skip to content

Instantly share code, notes, and snippets.

@ewenchou

ewenchou/README.md

Last active Mar 29, 2021
Embed
What would you like to do?
Run Python script as systemd service
  1. Create a service file like dash_sniffer.service
  2. Put it in /lib/systemd/system/
  3. Reload systemd using command: systemctl daemon-reload
  4. Enable auto start using command: systemctl enable dash_sniffer.service
[Unit]
Description=Dash Button Sniffer
[Service]
Type=simple
ExecStart=/usr/bin/dash_sniffer.py
[Install]
WantedBy=multi-user.target
@thatguycharan

This comment has been minimized.

Copy link

@thatguycharan thatguycharan commented Dec 4, 2017

I followed the same steps for my program lying on GCP but it didn't work.
I was trying to daemonize a python script made for polling a telegram bot.

@skyway22

This comment has been minimized.

Copy link

@skyway22 skyway22 commented Feb 12, 2018

Well, post the details (service file, script) so others can help.

@tinkerBOY-git

This comment has been minimized.

Copy link

@tinkerBOY-git tinkerBOY-git commented Feb 22, 2018

try:

ExecStart=/usr/bin/python /usr/bin/dash_sniffer.py

@matthijskooijman

This comment has been minimized.

Copy link

@matthijskooijman matthijskooijman commented Aug 22, 2018

Wouldn't it be better to put the file in /etc/systemd/system, rather than in /lib? They are both used, but AFAIK the latter is intended for installed packages, rather than administrator additions.

@crisscrt

This comment has been minimized.

Copy link

@crisscrt crisscrt commented Aug 29, 2018

  • add

#! /usr/bin/python to dash_sniffer.py

  • chmod 777 dash_sniffer.py
@KaranTrivedi

This comment has been minimized.

Copy link

@KaranTrivedi KaranTrivedi commented Jun 26, 2019

chmod 777 chesus crust

@romangraef

This comment has been minimized.

Copy link

@romangraef romangraef commented Apr 22, 2020

We all had that one guy who pulled a sneaky chmod 777 -R / on the server, right?

@ali-aliabadi

This comment has been minimized.

Copy link

@ali-aliabadi ali-aliabadi commented Jan 23, 2021

We all had that one guy who pulled a sneaky chmod 777 -R / on the server, right?

😂😂😂

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