I'm working with a batch script to perform data migration using the S3 sync command from an on-premises system to Amazon S3. The issue is that when I close the Command Prompt, the migration stops. I need a way to run this batch script in the background so it keeps executing even if the CMD window is closed. Additionally, I want to log the output with timestamps throughout the process. Any suggestions?
4 Answers
If you're looking for a more reliable solution, consider using AWS Systems Manager (SSM). You can register your server as a managed instance, allowing you to run the S3 sync using SSM documents. This method allows for execution in the background and on a schedule, plus it provides logging options to CloudWatch, so you’ll have timestamps built-in! It's a great way to handle things without being tied to local execution.
Just to clarify, are you alright using .bat files and still posting on forums like this? Just checking!
If you're familiar with Linux tools, using tmux or screen can keep processes running in the background. However, that's mostly for Unix-like systems, so for Windows, I recommend sticking to the scheduled task method.
It sounds like you might want to set up a scheduled task for your batch file instead. This way, it runs independently of whether you're logged in or not. Just configure the scheduled task to run in the background!
True, the Windows environment doesn't natively support those tools, so the scheduled task approach is your best bet!