1. Edit Timed Task Information
sudo crontab-e #以root用户创建, can also-u parameter
Edit the contents as follows:
Frequency expressions correspond to minutes, hours, days, weeks, and months, respectively.
Lang=zh_cn. UTF-8*/30 * * * * CD/USERS/ZIPONLLL/PYCHARMPROJECTS/EXPORTTODAYPV &&/export.sh
2.crontab when running Python scripts (not limited to Python, mainly system environment variables), found not running
Because it is run as root, it runs under the system environment variable, and the Python3 path is not found.
So add in the shell file to be executed (you can see the difference in the shell file before and after the source echo $PATH)
Source/users/ziponlll/.bash_profile
Examples are as follows:
echo $PATH >/users/ziponlll/>>"job start" >> -v>>/users/ziponlll/pycharmprojects/test/test.py >test.log 2>&1 &
3.crontab the following editing content, direct computer execution Python3 test.py file, Chinese will not error, use crontab Chinese will error, to add the following in the editor crontab
Lang=zh_cn. UTF-8
Mac/linux Self-timer task execution crontab use