树莓派指定时间运行代码

我想用树莓派每隔一个小时采集温湿度数据,不知道怎么实现每隔一个小时运行采集数据的代码,现在已经可以采集数据了

1.用系统定时任务,你的程序每执行一次要自动结束
2.把你的程序声明为服务,让它死循环一直运行,然后定期取系统时间,判断小时数是否变化

你可以用crontab来定时执行任务
运行

crontab -e

添加一行

0 * * * *  command to execute

参考
https://www.raspberrypi.com/documentation/computers/using_linux.html#scheduling-tasks-with-cron