Windows Scheduler
Schedule SFTP moves with Task Scheduler
Section titled “Schedule SFTP moves with Task Scheduler”We will move every .zip from C:\data\ to sftp://monitor02@10.0.0.24/incoming/ every ten minutes. The new connect move command mirrors send --delete: files land on the remote side and disappear locally once the transfer succeeds.
- Create an alias with stored credentials
Open Command Prompt and run:
C:\> connect alias addAlias name: job1Endpoint (no folder, e.g. sftp://host or s3://bucket): sftp://monitor02@10.0.0.24SFTP password (optional; recommended to leave blank in URI): ****Connection test: OKAlias 'job1' saved. You can now use it as @job1/.. in commands.The alias encrypts the password inside %USERPROFILE%\.connect\connect_aliases.enc, so it is safe to reuse from scheduled tasks.
- Trust the host key and verify access
C:\> connect ls @job1/The key (SHA256:v/goXq57T++lsDmeYduLCRJEUzEqf9u9OybWiHt3VRc) of 10.0.0.24:22 is unknown. Do you want to add this key to known_hosts (y/n): yName Size ModTimeincoming/ - 2024-12-10T10:44:51ZRun the command again to ensure the key is stored and no longer prompts.
- Create a batch file that runs
connect move
Use Notepad to save C:\connect\job1.bat with the following content:
@echo offc:\connect\connect.exe move ^ --batch --no-color --parallel 3 ^ "C:\data\*.zip" ^ @job1/incoming/ >> c:\connect\job1.log 2>&1- Test the script manually
C:\> c:\connect\job1.batC:\> type c:\connect\job1.log2024/12/10 15:36:12 INFO Moving files to sftp://monitor02@10.0.0.24/incoming/Clear the log if you want a fresh file before scheduling: type nul > c:\connect\job1.log.
- Register the task in Task Scheduler
- Press
Win + R, runtaskschd.msc. - Action → New Folder… create a folder named
SFTP(optional for grouping jobs). - Inside that folder choose Action → Create Task…
- General tab:
Name = Job1, select Run whether user is logged on or not. - Triggers tab: add a trigger with On a schedule, repeat every 10 minutes indefinitely.
- Actions tab: choose Start a program and point to
C:\connect\job1.bat. - Conditions tab: disable idle/power checks so the task always runs.
- Settings tab: enable Allow task to be run on demand and set If the task is already running → Do not start a new instance.
- General tab:
- Confirm with OK. When prompted for credentials, supply the Windows account that installed the alias.
- Validate the scheduled run
Right-click the task and select Run. Inspect C:\connect\job1.log for the latest timestamp or check the Task Scheduler History tab to confirm success.