[Python] List all daemon/service names in linux using Python?

Discussão em 'Python' iniciado por Stack, Julho 22, 2025.

  1. Stack

    Stack Membro Participativo

    I want to have list of all daemons/services in Linux using python. I am able to get information using

    service --status-all


    However I don't want to execute terminal commands through Python. Is there any API available to perform this operation?

    My project includes lots of stuff so I need to be careful with memory and cpu usage, also I may need to run the command every 10sec or 60sec depending on configuration. So I don't want to create too many process.

    Earlier I had used subprocess.check_output(command)

    But I was told by my manager to avoid using commands and try to use any available packages, I tried searching some but could found packages which can only monitor services and cannot list.

    Finally my objective is to minimize load on system. Any suggestions ?

    Additoinal details-

    Python 3.7.2
    Ubuntu 16

    Continue reading...

Compartilhe esta Página