简体   繁体   English

任务调度程序显示 python 脚本显示为正在运行但不工作

[英]Task scheduler shows python script shows as running but not working

I've been trying to run a lengthy Python script in the task scheduler in order to be able to run it for a long periods of time.我一直在尝试在任务调度程序中运行一个冗长的 Python 脚本,以便能够长时间运行它。 I've tried using bat files, inserting just the path to the actual python file, python.exe files, etc., but nothing seems to be working.我尝试使用 bat 文件,只插入实际 python 文件、python.exe 文件等的路径,但似乎没有任何效果。 I also have a path to another file in my script, I changed that to a full file path but nothing happens.我的脚本中还有另一个文件的路径,我将其更改为完整的文件路径,但没有任何反应。

The script, when I run it in cmd or VS code connects to an API and adds specified elements to a SQL Server, however when I run it from the Task Scheduler, the database remains empty and nothing is added despite the fact that it is 'running'.该脚本,当我在 cmd 或 VS 代码中运行它时,它连接到 API 并将指定的元素添加到 SQL 服务器中,但是当我从任务计划程序中运行它时,它仍然是空的,但它仍然是空的跑步'。

This is my current.bat file: "C:\Users\n\AppData\Local\Programs\Python\Python310\Lib\venv\scripts\nt\python.exe" "C:\Users\n\Desktop\data\shared_links.py" pause这是我的 current.bat 文件: "C:\Users\n\AppData\Local\Programs\Python\Python310\Lib\venv\scripts\nt\python.exe" "C:\Users\n\Desktop\data\ shared_links.py" 暂停

Eventually I got it to work.最终我得到了它的工作。 What I changed in the end that worked was changing the path to the pyton.exe file to C:\Users\AppData\Local\Programs\Python\Python310\python.exe, as my previous one was a virtual environment path.我最终所做的更改是将 pyton.exe 文件的路径更改为 C:\Users\AppData\Local\Programs\Python\Python310\python.exe,因为我之前的路径是虚拟环境路径。 I also added @echo off in the beginning and deleted pause at the end of my.bat file.我还在开头添加了@echo off,并在 my.bat 文件的末尾删除了 pause。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM