linux-用crond定时执行python脚本-不执行时的一种解法
2020-07-29 15:08
204 查看
安装
yum install vixie-cron crontabs
查看服务状态
service crond status
开启
service crond start
加入开机服务中
chkconfig –level 35 crond on
查看crontab服务列表
(base) [root@localhost ~]# crontab -l no crontab for root
说明现在没有定时任务。
编辑服务列表
crontab -e
这样会打开一个vim界面,编辑即可
08 14 * * * /home/software/anaconda3/bin/python3 /mnt/share/test.py
这个test.py我只写了一个打印“谢谢”到test.txt文件的函数,没有引用任何额外包。这是可以正常执行的。前面表示每天14:08分执行这个任务。
时间设定说明
(base) [root@localhost share]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # For details see man 4 crontabs # 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
python脚本不执行
我遇到的情况是,我用的是anaconda的一个环境,那么我要引入该环境的解释器,然后在我指定的路径下执行脚本。这样才会在指定时刻执行任务。
0 23 * * * export PATH=/这是python路径/bin/:$PATH;cd /脚本所在路径;python3 脚本名.py
相关文章推荐
- linux下定时执行python脚本方法
- 记录linux设置定时执行python脚本以及输出到指定文件
- linux下使用crontab定时执行python脚本
- Linux crontab定时执行Shell脚本时的一个小坑:一种类似场景 (当需要执行特定的命令时) 解决思路
- Linux下定时执行python脚本
- linux下使用crond 定时执行php脚本
- Linux环境下crontab定时执行Python脚本(远程)
- Linux下定时执行脚本。转自:http://www.blogjava.net/decode360/archive/2009/09/18/287743.html
- Crontab 让linux定时执行shell脚本
- linux定时执行脚本
- linux定时执行脚本
- linux下定时执行php脚本
- Centos定时执行python脚本
- Ubuntu系统使用Shell脚本定时执行python脚本
- linux下使用crontab定时执行脚本,简单实用
- linux定时执行脚本
- Linux直接./xx.py执行python脚本时报错
- crontab 定时执行python脚本
- python脚本清除linux cron中过期的定时计划
- 使用crontab,让linux定时执行shell脚本