armbian系统crontab无效

crontab用来作为计划任务再合适不过了

可是最近在使用的过程中碰到问题

以为很简单

无非是没有安装cron,于是apt-get install cron

service cron restart

发现都不行

最终找到原因,这和平时用的cron不太一样

平时我们只需要crontab -e然后按规则写入计划任务即可

在armbian中必须在`/etc/crontab`中写入任务

示例

```
root@orangepipc:~# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# 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 executed
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 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 7-23 * * * root /usr/bin/python2.7 /mnt/shell/tts.py
30 7-23 * * * root /usr/bin/python2.7 /mnt/shell/tts.py
32 07 * * 1-5 root /usr/bin/mpg123 /mnt/music/opi/*.mp3
40 07 * * 1-5 root /usr/bin/python2.7 /mnt/shell/tts.py
45 07 * * 1-5 root /usr/bin/python2.7 /mnt/shell/tts.py
50 07 * * 1-5 root /usr/bin/python2.7 /mnt/shell/tts.py
55 07 * * 1-5 root /usr/bin/python2.7 /mnt/shell/tts.py
```

最后记得添加规则后要执行`service cron restart`

输入`service cron status`可以看到执行的日志

    A+
发布日期:2021年07月12日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: