我一直试图让 crontab 工作一段时间,但它似乎不想工作。我需要在每个午夜初始化的 python 脚本在命令终端上完美运行。我的 python 脚本的位置是:
/home/rv/ncbi-blast-2.2.23+/database_backup/backup.py
我的 contab 如下所示:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/home/rv/ncbi-blast-2.2.23+/database_backup
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
# | | | | |
# * * * * * command to be executed
0 0 * * * /usr/bin/python /home/rv/ncbi-blast-2.2.23+/database_backup/backup.py
我的 python 脚本如下所示:
#!/usr/bin/python
from subprocess import Popen
import datetime
today = datetime.date.today()
today = str(today)
#print today
f = open("/home/rv/ncbi-blast-2.2.23+/database_backup/%s.sql" % (today), "w")
x = Popen(["mysqldump", "-u", "root", "-p*****", "normalisation"], stdout = f)
x.wait()
f.close()
知道我哪里出错了吗?
只是查看了 cron 日志,每次尝试输入时我都得到了这个
(root) BAD FILE MODE (/etc/crontab)
当我尝试使用 shell 脚本时,我也遇到了同样的错误