I am running an AWS Windows 2012 EC2 instance that has to run 24/7. On this instance, I run a Python 3.6 scraper script and to prevent me from having to regularly check up on the server whether the file is running, I have a .bat
file in the shell:startup
folder of my instance, that automatically restarts it on a daily base. The .bat
file works as it will run the Python script and set a timer to restart/reboot the instance after (t=86400
). The .bat
file runs on the EC2 instance itself.
However, what the file does not do is run automatically after the reboot. I now first have to remote connect to the server before the .bat
file will run. What I want it to do is run without me having to first remote connect into the server. How can I achieve this?
I use the following code in my .bat
file. Located on my EC2 instance.
@ECHO OFF
START CMD /K (
CD C:/Users/Administrator/Documents/
python scraper.py
)
START CMD /K SHUTDOWN -t 86400 -r -f
I have tried looking into using AWS' Automations and other schedule based methods but couldn't get that to work.