sudo -H -u {username} /bin/bash -c "python test.py &"
"&" 后台运行指令
本人亲测可用,切换到root权限后,指定了 lowman 用户运行 test.py 文件: