树莓派定时任务不生效

时间:2022-07-28
本文章向大家介绍树莓派定时任务不生效,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

过程

设备树莓派zero w

执行定时任务不生效,脚本crontab -e & sudo crontab -e均不行

查询一番发现树莓派定时任务设计命令为

sudo nano /etc/crontab

以下是官网命令,和平时Linux些许不同

# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  * user-name command to be executed17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

修改后

0 * * * * pi /home/pi/shell/jijin.sh

少了秒的概念,同时增加了执行用户