Skip to main content

A systemd binding Library in Python

Project description


PySystemd is a Python library for managing and interacting with system services using systemd. This library provides functionality to check the status of services, manage service states, list services, manage power operations, and retrieve system status information.


  • ServiceStatus: Check if a service is running or enabled, and retrieve detailed status information.
  • ServiceManager: Start, stop, restart, reload, enable, and disable services.
  • ServiceLister: List all services, running services, not running services, enabled services, and disabled services.
  • PowerManager: Perform power operations like power off, reboot, rescue, and suspend.
  • SystemStatus: Get system uptime and load average.


pip install pysystemd

or simply clone this repository and import the required classes into your project.


Checking Service Status

from pysystemd import ServiceStatus

service = ServiceStatus('apache2')
print(service.is_running())  # Check if the service is running
print(service.is_enabled())  # Check if the service is enabled
print(service.get_status())  # Get detailed status of the service

### Managing Services

from pysystemd import ServiceManager

manager = ServiceManager('apache2')
manager.start()    # Start the service
manager.stop()     # Stop the service
manager.restart()  # Restart the service
manager.reload()   # Reload the service
manager.enable()   # Enable the service
manager.disable()  # Disable the service

Listing Services

from pysystemd import ServiceLister

print(ServiceLister.list_all())          # List all services
print(ServiceLister.list_running())      # List all running services
print(ServiceLister.list_not_running())  # List all not running services
print(ServiceLister.list_enabled())      # List all enabled services
print(ServiceLister.list_disabled())     # List all disabled services

Power Management

from pysystemd import PowerManager

PowerManager.poweroff()  # Power off the system
PowerManager.reboot()    # Reboot the system
PowerManager.rescue()    # Boot to rescue mode
PowerManager.suspend()   # Suspend the system

System Status

from pysystemd import SystemStatus

print(SystemStatus.uptime())        # Get system uptime
print(SystemStatus.load_average())  # Get system load average


PySystemd uses Python's built-in logging module to provide detailed logs of its operations. By default, the logging level is set to INFO and the format includes the timestamp, log level, and message.


Contributions are welcome! Please fork the repository and submit pull requests for any features, bug fixes, or improvements.


This project is licensed under the LGPL v3 License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysystemd-1.1.tar.gz (6.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page