14 lines
442 B
Python
Executable File
14 lines
442 B
Python
Executable File
#!/home/andrei/it_school/bin/python3
|
|
|
|
import sys
|
|
import subprocess
|
|
|
|
def check_service_status(service_name):
|
|
try:
|
|
# Run the systemctl command to check the service status
|
|
result = subprocess.run(['systemctl', 'is-active', service_name], capture_output=True, text=True)
|
|
return result.stdout.strip() == 'active'
|
|
except Exception as e:
|
|
print(f"Error checking service status: {e}")
|
|
return False
|
|
|