擅长:python、mysql、java
<blockquote>
<p>I will run the script as a cron. Is it possible to run this with sudo?</p>
</blockquote>
<p>您可以将<code>python script.py</code>放入具有足够权限的用户的cron中(例如root用户或对相关文件和设备具有权限的用户)</p>
<p>我不知道您使用的是哪个操作系统,但是如果Raspbian与Debian很接近,那么就不需要sudo或root,只需使用具有足够权限的用户。在</p>
<blockquote>
<p>It seems I can also do this <code>check_output check_output(["sudo", "/home/pi/bin/lol_dht22/loldht", "7"], timeout=10)</code></p>
</blockquote>
<p>当然,但是要调用Python脚本的unix用户需要sudo特权(否则不能从<code>subprocess</code>调用<code>sudo</code>)。在这种情况下,您可以执行上述操作,从具有所需权限的用户运行cron。在</p>