Python to Get Windows Scheduled Tasks Status - python

I have a Windows scheduled task which does some database updates and it runs every few hours.
I have a Python script which updates data in the same database, and it is called by the users.
I want to prevent data conflict between the scheduled task and Python script. When a user calls the Python script, how can I check if the scheduled task is running, so that the Python script delays updating the database until the scheduled task is finished? Or would it be easier to check if the database is being updated (how would I do this in Python script?)?
I am running Python 2.7 64-bit, Windows Server 2012 64-bit and SQLServer 2012 64-bit.
Thanks in advance.

Related

How do I keep my python backend scripts running forever on Microsoft Windows?

I want to keep my Python scripts running forever on Windows Server 2012.
I tried using MS Windows Task Scheduler, but it keeps creating new instances of the script every time and hence, fills my memory. Currently I run my scripts through command prompt and keep them minimized, and I never log out from the Server.
Any help is really appreciated.
You could use https://learn.microsoft.com/en-US/windows-server/administration/windows-commands/sc-create to create a service then use Scheduled Tasks to control it.

Windows task scheduler issue python script automation

I'm running a python script using the task scheduler. The script gets data from a database using pandas and stores them in csv.gz files.
It's running properly but there is a difference in data size when the Task Scheduler runs automatically and when it is run manually via Task scheduler run button. The manual run gets all the data, whereas automated run gets lesser data.
It runs the same script. I've checked multiple times. But unable to identify the issue.
PS:
Using Windows Server 2008, pymssql to connect to Database

scheduler for running python scripts

I have a python script which installs a build from server to a node.
Now I want to schedule the task to a specific time, so that it triggers automatically.
One way is the windows scheduler to trigger batch file which internally calls runs the python script.
Do python have built-in support for this.
It should be OS independent, runs on both windows and linux platform.
Any ideas?
I've used this lightweight scheduler before to handle cron tasks -> https://github.com/mrhwick/schedule
I'd highly recommend it.

Windows Task Scheduler vs. Windows Service with Advanced Python Scheduler

I have a Python middleware application which polls a site for content, and then writes/updates a JSON file for a client-side web application.
I've investigated several ways for hosting this Python application on a Windows Server 2003 machine. I've set up the application to run every minute under the Windows Task Schedule, and have also looked at installing the application as a Windows Service (via NSSM).
Ideally, I'd like the application run continuously as an NSSM-managed Windows Service, with an internal task scheduler function to poll the various required sites every X seconds.
Would this be an acceptable solution? Or should I remove all polling components of the Python application, and use Windows Task Scheduling as the polling mechanism?

Python script involving Outlook through win32com runs when double-clicking, but not through task scheduler

I have a python script that sends out an email using win32com and Outlook. The script runs without a hitch when I run it through an interpreter or double-click on the script. However, when I run it through the Task Scheduler, I get the following message:
"Something went wrong. We couldn't start your program. Please try starting it again. If it won't start, try repairing Office from 'Programs and Features' in the Control Panel."
I'm using Office 365, and Python 2.6. I've tried running the script through the scheduler after killing the Outlook process, but I ran into the same issue.
Office isn't designed to run as a service, and needs to be run interactively. You'll need to change your task configuration in Task Scheduler to run the task as the currently logged-in user, on the current user's desktop, with the current user's privileges.

Categories

Resources