Cron execution of python failed

execute the print output in the following crontab,xxx.py file:
18 16 * / usr/local/python3/bin/python3.7 / root/xxx.py

1. Confirmed the normal operation of cron and tested the timing output

2. Confirmed that / usr/local/python3/bin/python3.7 / root/xxx.py can be executed and got the correct result

3. Confirmed that / var/log/cron has content, and saw the execution of this scheduled task. The record is as follows:
Nov 23 16:01:02 localhost run-parts (/ etc/cron.hourly) [17754]: finished 0yum-hourly.cron
Nov 23 16:10:01 localhost CROND [17949]: (root) CMD (/ usr/lib64/sa/sa1 1)
Nov 23 16:17:04 localhost crontab [18958]: (root) BEGIN EDIT (root)
Nov 23 16:17:36 localhost crontab [18958]: (root) REPLACE (root)
Nov 23 16:17:36 localhost crontab [18958] : (root) END EDIT (root)
Nov 23 16:18:01 localhost crond [1076]: (root) RELOAD (/ var/spool/cron/root)
Nov 23 16:18:01 localhost CROND [19014]: (root) CMD (/ usr/local/python3/bin/python3.7 / root/xxx.py)
Nov 23 16:20:01 localhost CROND [19630]: (root) CMD (/ usr/lib64/sa/sa1 11)
Nov 23 16:21:31 localhost crontab [19849] : (root) BEGIN EDIT (root)
Nov 23 16:23:50 localhost crontab [19849]: (root) END EDIT (root)

4. Confirmed that / usr/local/python3/bin/python3.7 / root/xxx.py > > x.log can be executed and added 2 > & 1. X.log has normal program output records

.

freaked out and felt that it was all right to check it. All the commands used an absolute path, that is, there was no execution result, and there was no record of intermediate execution output, so it seemed that they had not been executed

.
Dec.11,2021

has encountered a similar situation before, when the problem was that the file needed to rely on other files. If the current working directory is not the project's directory, the dependency

will not be found. The better way to

is cd target_dir & & / path/to/python xxx.py


what run results do you want? Tasks in crontab will be output to email if they are not redirected. You can look in the / var/mail/root file to see if there are any output results.

Menu