How to Run a Python Script with the Windows Task Scheduler - Run Scheduled Python Scripts

Ғылым және технология

If you liked the content, please consider checking out my Patreon! - / membership Hey everyone, in today's video we take a look at how to run a python script on a set schedule with the task scheduler in windows. Thanks for watching!
My Favorite Python Book - amzn.to/3IWJ7zX
Check out my Website for more Content - codingunderpressure.com/

Пікірлер: 58

  • @Createme99
    @Createme9911 ай бұрын

    FYI - my Task Scheduler didn't like the spaces in my .py filename so I removed those and it worked! This video is tremendous, thank you

  • @south828

    @south828

    Ай бұрын

    you can also put in inside double quotes "D:/Some Folder/your file name.py" it helps if your folders have spaces in their names or you can follow PEP8 and use underscores

  • @glenn8781
    @glenn8781 Жыл бұрын

    Simple and perfectly explained. Thank you!

  • @thesilenthero422
    @thesilenthero4226 ай бұрын

    Thanks for this - helped me set up my daily script to keep running while I'm on vacation 😆

  • @user-qe5st3wz2f
    @user-qe5st3wz2f7 ай бұрын

    Incredible, you have just opened my eyes, thank you

  • @mijoizagas3747
    @mijoizagas3747 Жыл бұрын

    Very cool, well done sir!

  • @kdspland
    @kdspland3 ай бұрын

    This is extremely helpful.

  • @LucasSilva-pd8kn
    @LucasSilva-pd8kn7 ай бұрын

    Now i see why it didn't triggered my script! Thanks, man!

  • @Veigaburame
    @Veigaburame Жыл бұрын

    work for me, thank you a lot!

  • @samk1491
    @samk1491 Жыл бұрын

    Thank you bro ur video was very helpful

  • @sushilparajuli007
    @sushilparajuli0077 ай бұрын

    thank you, very helpful !!

  • @manujamadushan9471
    @manujamadushan9471 Жыл бұрын

    Thanks ! It worked 🤟

  • @user-qf1zg3xw7v
    @user-qf1zg3xw7v11 ай бұрын

    Thank you so much for the video

  • @anurodhchoudhary1689
    @anurodhchoudhary1689 Жыл бұрын

    thanks, it works :)

  • @alonsopg931
    @alonsopg93111 ай бұрын

    Thank You very much!

  • @RizkySamPratama
    @RizkySamPratama Жыл бұрын

    Perfect, thanks

  • @saivineelkumar
    @saivineelkumar2 жыл бұрын

    Good info

  • @vishavgupta3717
    @vishavgupta37172 жыл бұрын

    Thank you dude

  • @user-io6zj1cc1q
    @user-io6zj1cc1q8 ай бұрын

    Thank you so much!!!

  • @user-qe5st3wz2f
    @user-qe5st3wz2f3 ай бұрын

    perfect thank you very much

  • @oyindamolavictor
    @oyindamolavictor Жыл бұрын

    Perfect... was already wondering how I could integrate cron into windows server... maybe git bash can make it work... eitherway, I am going to try this now

  • @khalilebdelli6199
    @khalilebdelli6199 Жыл бұрын

    hello, great video , thank you so much for the detailed explanation and example . i tried to implement the same idea on a project I'm working on , sadly I ran into a small imperfection , whenever my automated python script runs , a small python console window opens up and then disappears and then i get the expected output , please if you have any idea on how to remove the python console window let me know , i really appreciate it , thank you

  • @chanduy1843
    @chanduy18437 ай бұрын

    Thank you

  • @dyahlangensari4802
    @dyahlangensari480215 күн бұрын

    Hi, does this task scheduler need any internet or wifi to run? Thx for the video anyway, it really helps me a lot! Xoxo

  • @madhusudhanak4394
    @madhusudhanak4394 Жыл бұрын

    am seeing fallowing error a specified logon session doesn't excites

  • @ivanm3214
    @ivanm32145 ай бұрын

    great video! however, it doesn't work for me. the task refuses to run on schedule (every 5 mins) but it runs when I trigger it manually. any idea why the trigger wouldn't work?

  • @kubamosakowski7350
    @kubamosakowski73508 ай бұрын

    thanks

  • @monkeynoaim
    @monkeynoaim2 ай бұрын

    does it works for automations using pyautogui library?

  • @ibecristiano983
    @ibecristiano983 Жыл бұрын

    Hi I have a request. Can you set up an automatic schedule to lock files and ask for a new password? for example: A file I send to another person on a different device will be locked in the next 1 hour. The file can be opened again with my permission and using a new password. thankyou

  • @jibinbhagianath4708
    @jibinbhagianath470829 күн бұрын

    hi.my python webscraping scripts are running perfectly but even after the script perfectly ran if i check the task manager i am seeing the python and the browser still open and the ram and cpu is consumed. eventhough the browser and the py file is closed. is there a way to fix this

  • @jessefreitag5374
    @jessefreitag5374 Жыл бұрын

    0x2331 error Thanks, does anyone know why I am getting this error? I have python thru anaconda.

  • @iN0F
    @iN0F3 ай бұрын

    thx

  • @goldensleeves
    @goldensleeves2 жыл бұрын

    Great video. However, could I use this for a jupyter notebook file (.ipynb) somehow as well? Or would I only be able to task schedule the .py type file? Thanks in advance!

  • @tushardeepsingh4976

    @tushardeepsingh4976

    Жыл бұрын

    Download ipynb as py then it would work

  • @louisdonofrio7376

    @louisdonofrio7376

    Жыл бұрын

    @@tushardeepsingh4976 I did that but I still get issues where it says the directory is invalid. I have python through anaconda and jupyter lab. Is there a different python I need to download or a different way I need to map to it? Thanks in advance

  • @vaggelismanousakis6147
    @vaggelismanousakis61475 ай бұрын

    As soon as I created the task at 7:00 I couldn't find the task in the task list. I figured that visiting C:\Windows\System32\Tasks or running "schtasks.exe /query" on the command line I could find it there but it was in Status: Ready and to test it I set the time to 5' but it never run :(

  • @CharlesClarke-bl9pj
    @CharlesClarke-bl9pj2 ай бұрын

    I understand that the script will run even if I am logged on. Silly question, but will it run if my computer is sleeping also?

  • @starriet
    @starriet2 жыл бұрын

    *second nice tutorial anyways!

  • @henri_poincare
    @henri_poincare11 ай бұрын

    When I setup tasks on the task scheduler using a local repository with a virtual environment I point to the python interpreter in .../.venv/Scripts (given your venv is named .venv) and enter the root of my local repo as the start in option, due to the fact my script is usually in something like .../src/py/main.py and the script is usually referencing paths in .../data/in/data.csv (i.e. paths are not hardcoded)

  • @paololigori

    @paololigori

    10 ай бұрын

    thank you, just what i was about to ask!

  • @tushardeepsingh4976
    @tushardeepsingh4976 Жыл бұрын

    Hi . When I try to run your code task scheduler works But when I run my py script which contains 3 lines of code to import pandas then read a csv file and write some rows of this csv to an excel at sone location . Import pandas as pd df= pd.read_csv(r’c:\files\abc.csv’) df.to_excel(‘c:\files\op.xlsx’,index=False) Task scheduler is not running this code . This code is running correctly in Jupiter notebook however not running by task scheduler when used as .py file Please tell what’s that I’m missing

  • @anthonysottile8432

    @anthonysottile8432

    Жыл бұрын

    Did you figure out how to fix this?

  • @adityanjsg99

    @adityanjsg99

    6 ай бұрын

    Bro, you cant tun a .ipynb file (Jupyter notebook) via python prefix. It has to be .py file only

  • @bradwilson4410
    @bradwilson4410 Жыл бұрын

    Any idea on how to run this without any windows popping up? I see that yours does not. I have tried the pyw extension, but that doesn't work. I want my script to run in background while I can continue to work on my computer; without it popping up every hour. Any ideas would be greatly appreciated!

  • @trentrob8894

    @trentrob8894

    11 ай бұрын

    I had this problem too. I figured out you have to check the box that says "Run whether user is logged on or not". This will make the window no longer pop up when the task is executed.

  • @Lexcepcion
    @Lexcepcion2 жыл бұрын

    Can you please make a video on how to do this when the user is logged off? I check the whether user is logged in or not option to no avail. Thanks.

  • @damebanda3180

    @damebanda3180

    2 жыл бұрын

    Any progress? I've tried running "ctypes.windll.user32.SystemParametersInfoW(20, 0, r'C:\Users\username\Pictures\bg.jpg' , 0)" on python through the scheduler, but it seems to not run it at all when "Run whether user is logged in or not" is checked.

  • @henri_poincare

    @henri_poincare

    11 ай бұрын

    idk if this helps but this will work if you are logged on but you lock your machine.

  • @codebusters007
    @codebusters007 Жыл бұрын

    I get 0x2331 error when running the script. Why? :)

  • @jessefreitag5374

    @jessefreitag5374

    Жыл бұрын

    I am getting the same error.. did you end up getting this addressed?

  • @dodobird809
    @dodobird809 Жыл бұрын

    it says task scheduler cannot create the task. user account unknown, password incorrect, or user account does not have permission to create. I have correct password. what does user account unknown mean? how do I giver permissin?

  • @sharmilak4155

    @sharmilak4155

    Жыл бұрын

    Even I encountered the same problem

  • @dodobird809

    @dodobird809

    Жыл бұрын

    @@sharmilak4155 try disabling the run when logged in/out thing. i turned it to logged in and it works

  • @AbdirahimAli10
    @AbdirahimAli10 Жыл бұрын

    how to check if python script is running or not

  • @adityanjsg99

    @adityanjsg99

    6 ай бұрын

    That text file maintains log, by checking the last time stamp, you can figure it out

  • @Xcerptshow
    @Xcerptshow27 күн бұрын

    Lets Go Brandon!

  • @SLWarLord
    @SLWarLord8 ай бұрын

    You didn't say to check whether Python is installed first 😁

  • @PawanSharma-ui2oz
    @PawanSharma-ui2oz2 жыл бұрын

    *first

Келесі