我用过
/etc/crontab。我使用
vi并在该文件中输入了所需的PATH,然后以root身份运行它。普通的crontab会覆盖您设置的PATH。关于如何执行此操作的很好的教程。
系统范围的cron文件如下所示:
This has the username field, as used by /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.# This file also has a username field, that none of the other crontabs do.SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user command42 6 * * * root run-parts --report /etc/cron.daily47 6 * * 7 root run-parts --report /etc/cron.weekly52 6 1 * * root run-parts --report /etc/cron.monthly01 01 * * 1-5 root python /path/to/file.py



