Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I automatically run a jupyter notebook (with Anaconda) on startup using Windows Scheduler

I have a notebook that automatically queries a database, and then pushes the results to a google sheet every hour, but needs to be constantly running on a computer to work. How can I automatically run a Jupiter notebook when my computer starts up (I reboot a lot) Thanks!

like image 724
Matthew P Avatar asked Mar 04 '23 22:03

Matthew P


1 Answers

I didn't actually tried with Anaconda but the solution should be comparable. The idea is to create vb script and run it from the scheduled task.

  1. Create jupyter-cron.vbs

    Set run = WScript.CreateObject("WScript.Shell")
    run.Run "jupyter-notebook.exe --no-browser --notebook-dir=C:\Notebooks", 0, True
    

    Note: Use --no-browser option to prevent browser to start. The script will run with the hidden window. Do not forget to update path to the notebook directory.

  2. Create jupyter-cron.bat

    start /B "C:\Windows\SysWOW64\cscript.exe" "C:\Localdata\jupyter-cron.vbs"
    

    Note: This location applies for 64-bit system, for the 32-bit system use C:\Windows\System32\cscript.exe. Do not forget to update path to vbs script.

  3. Define scheduled task to run on system startup Trigger Action

like image 200
Johnny Avatar answered Apr 30 '23 20:04

Johnny