I have a simple python code should be run as root. sudo --preserve-env=HOME python3 <file_name>
works perfect for me, but, in order not to write this every time, I made the shebang in my code: #!/usr/bin/sudo --preserve-env=HOME python3
— and started it as an usual executable file.
I have made a sudo-shebangs so I didn't expect something to be wrong, but when I started it, it didn't run, but it started to eat RAM. Even the first logging string of code (even before imports) wasn't executed, when it has already eat all the RAM.
Then I remade the shebang to #!/usr/bin/env sudo --preserve-env=HOME python3
(env
was added). But then something weird started. This doesn't eat RAM anymore, but CPU... Two cores started some weird dance: the first core is overloaded, the second is resting, then they are being swapped. This repeats regularly and cadencially. Sometimes the second core can be shifted by another one.
What can be the reason of the behavior?