Domanda

I was wondering what is the best way (if there's any) of knowing what run-level I (well... my Python script) is in. (You know... 0--> Halting, 1--> Single user, 2345--> Kind of regular run, 6 --> Rebooting)

I've been taking a look to the os, sys and subprocess libraries, but none of them seem to have anything that returns the run-level of execution.

I know I can execute the system's runlevel command, but I would be surprised if Python didn't have something more... "native" for it.

Thank you in advance

È stato utile?

Soluzione

I guess you are stuck using the 'runlevel' command, nothing native for Python. The result would be useless anyway, because it dependents on the distribution. Some distributions implement an other meaning to the same number. So no standardization in this area.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top