是否有python模式可以跟踪执行的每一行,类似于"bash -x"? [英] Is there a mode of python that traces each line executed, similar to 'bash -x'?

查看:53
本文介绍了是否有python模式可以跟踪执行的每一行,类似于"bash -x"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在crontab中运行一个python脚本,该脚本可以从命令行正常运行,但是在cron中运行时似乎根本没有运行.如果这是一个bash脚本,我将在crontab中添加"bash -x",并将STOUT和STDERR用管道传输到日志文件.是否有类似的python模式可以捕获脚本中每行代码的执行?

I am running a python script in crontab that works fine from the command line but appears to not be running at all when it runs in cron. If this was a bash script, I would add 'bash -x' to the crontab and pipe STOUT and STDERR to a log file. Is there a similar mode of python that will capture the execution of each individual line of code within a script?

推荐答案

跟踪模块这样做.

python -m trace --trace yourscript.py

这篇关于是否有python模式可以跟踪执行的每一行,类似于"bash -x"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆