1.crontab命令操作指导,因为刚开始进入编辑模式,不知道保存退出是啥样的,这里敷个教程。

操作命令如下:
crontab -u root -e 打开crontab的配置文件,并编辑完成
Ctrl + O 写入内容, 出现File name to Write …,输入Enter
Ctrl +X 保存并输出,保存完成
配置定时任务时间介绍:
每一分钟执行 /1
每五小时执行 0 /5
每天执行 0 0
每周执行 0 0 0
每月执行 0 0 1
每年执行 0 0 1 1 *
界面如下:
编写脚本的时候,一定要导入python环境变量, 要不容易不执行,这里我卡好久才最后发现是环境变量的问题,要么就是脚本权限的问题
# Edit this file to introduce tasks to be run by cron.## Each task to run has to be defined through a single line# indicating with different fields when the task will be run# and what command to run for the task## To define the time you can provide concrete values for# minute (m), hour (h), day of month (dom), month (mon),# and day of week (dow) or use '*' in these fields (for 'any').## Notice that tasks will be started based on the cron's system# daemon's notion of time and timezones.## Output of the crontab jobs (including errors) is sent through# email to the user the crontab file belongs to (unless redirected).## For example, you can run a backup of all your user accounts# at 5 a.m every week with:# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/## For more information see the manual pages of crontab(5) and cron(8)## m h dom mon dow command22 20 * * * export PATH=/usr/bin/:$PATH;cd /home/array/src;python3 run.py

2.编辑内容保存之后,查看命令crontab -l

3.然后配置完成之后,确定任务是否启动,去查看你执行的任务是否产生log或者标志性东西
比如我的python3 run.py执行之后,report目录下会产生log

