rc.local
/home/pi/home/gate/run.sh &
exit 0
/home/pi/home/gate/run.sh
#!/bin/sh
cd /home/pi/home/gate
export CREDENTIALS=credentials.json
sudo -E -H -u pi sh -c 'python3 localclient.py > log.txt 2>&1'
我全部进入log.txt(更新-加上一些调试打印信息,最初我忘记设置PYTHONUNBUFFERED = 1):
getrandom indicates that the entropy pool has not been initialized. Rather than continue with poor entropy, this process will block until entropy is available.
我还使用sudo
是因为su - pi
不起作用(我导入错误,也许是因为它没有设置$ HOME?)
如果我手动运行run.sh
(启动时不会自动运行),那么它将起作用。
此外,该过程使用所有cpu(同时阻塞直到更多的熵?),并且pi变热。