armbian系统crontab无效

发布时间:2021-07-12 01:03:24 阅读:3005次

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可以看到执行的日志

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:armbian系统crontab无效 出自老鄢博客 | 欢迎分享