systemd

sh: 1: rsync: not found

sh: 1: rsync: not found Question: I made a python application and its running fine. So now i made a service still all fine. last part of my program was to sync some files to a different server, rsync command works when i run it as my own users. only when it runs with the …

Total answers: 1

How to set the LANG for a python script running through systemd?

How to set the LANG for a python script running through systemd? Question: On the server where I run the program the default encoding is latin-1, and when I try to run a python script I get an error like ‘latin-1’ codec can’t encode characters in position, etc. I know you can change the default …

Total answers: 1

Use Systemd Watchdog with python. Muliprocessing

Use Systemd Watchdog with python. Muliprocessing Question: How to reset Systemd Watchdog using Python? I’m implementing a watchdog for a multi-threaded picture detection software with many dependencies. Previously, the service started a shell script, but now it starts the Python file directly. However, the watchdog implementation is not functioning correctly. Is there a more effective …

Total answers: 1

Query python systemd.journal like journalctl -b and journalctl –list-boots for entries related to last boots

Query python systemd.journal like journalctl -b and journalctl –list-boots for entries related to last boots Question: I’m looking for a way to query the information provided by journalctl -b and journalctl –list-boots through python systemd module. I’ve written a workaround which runs journalctl as a subprocess and parses the output. Maybe there’s some more obvious …

Total answers: 1

Way to pass arguments to FastAPI app via command line

Way to pass arguments to FastAPI app via command line Question: I’m using python 3.8.0 for my FastAPI app. It uses the .env file located on the root of a project directory. I am using the dotenv package, and the location of the .env file is hardcoded within the app. Here is my unit file …

Total answers: 1

Python Module not Found from `systemd` service Script

Python Module not Found from `systemd` service Script Question: With the dozens of previous answers, I’m surprised I couldn’t find anything… I’m using the paho mqtt library for a very simply python program to report out some data (running on a Raspberry Pi). My import from within the python program (my_program.py) is: import paho.mqtt.client as …

Total answers: 3

Python subprocess, realtime print with COLORS and save stdout

Python subprocess, realtime print with COLORS and save stdout Question: Printing the output of a subprocess while saving the result is not a new problem, and has been answered many times before e.g.: https://stackoverflow.com/a/28319191/5506400 This does not work for me because I am trying to maintain the shell colours printed. E.g. when one goes systemctl …

Total answers: 3

How to log to journald (systemd) via Python?

How to log to journald (systemd) via Python? Question: I would like logging.info() to go to journald (systemd). Up to now I only found python modules which read journald (not what I want) or modules which work like this: journal.send(‘Hello world’) Asked By: guettli || Source Answers: python-systemd has a JournalHandler you can use with …

Total answers: 4