Solved

How can I use Windows Task Scheduler to query records from a Postrgres database and append them to an ArcGIS Enterprise Portal table using FME?

  • 15 February 2022
  • 2 replies
  • 10 views

I am attempting to append records to an ArcGIS Enterprise Portal table from a Postgres database using an SQL statement.

 

I have a SQL statement that works correctly to query the database. I can use this in the SQL Creator Transformer and connect it to an Esri ArcGIS Portal Feature Service writer in FME Workbench. I can run this in FME workbench, and the records successfully write to the Portal table. The project works on my local machine and on the network server we plan to use for scheduled tasks. FME is installed on the server.

 

I would like to run this on a 12-hour interval using Windows Task Scheduler.

 

Here's what I've tried:

  1. Copied the "header text" from the log in FME Workbench, and saved this as a .BAT file.
  2. Placed the .FMW and .BAT files in the same directory on a network server, and edited the .BAT file to point to the .FMW file in its new location.
  3. I created a new scheduled task in Windows Task Scheduler to Start a program, and pathed to the .BAT file.
  4. Nothing is written to the Portal table when the Task is Run.
  • Note: Running the project in FME Workbench on this machine writes records to the Portal table successfully.

Here are the .BAT file contents:

C:\\Program Files\\FME\\fme.exe C:\\RUN\\FME\\snow_events\\snow_events.fmw

          --SourceDataset_POSTGRES weatherPost

          --SourceDataset_POSTGRES_5 weatherPost

          --DestDataset_ARCGISPORTALFEATURES https://maps.gov.yk.ca/portal

 

I have set up and run scheduled tasks in Windows Task Scheduler before. I have not done this with FME files. Can someone help me learn what I am missing?

Thanks for any help.

icon

Best answer by ryan.gould 2 March 2022, 16:18

View original

2 replies

Userlevel 2
Badge +10

Hi @ryan.gould​ great question! Running workspaces in Task scheduler can get a bit more tricky when there are database and web connections involved, which is the case here. This Question of the Week: Running a workspace with Windows Scheduler article does a great job of going over the reasons why connections can cause many issues. FME Server is also another option and makes scheduling workspaces in FME a very simple task.

Hope this helps!

Hi @danminneyatsaf​, thank you for the response. It turned out there were some syntax errors in my CMD and BAT files. The database connection in the FME workspace was also broken. Once I fixed these issues I was able to successfully run the .FMW file. Thank you for the link and FME Server suggestion.

 

.CMD file contents

@echo off

 

cd c:\\RUN\\FME\\snow_events

snow_events.bat

 

.BAT file contents

"C:\\Program Files\\FME\\fme.exe" C:\\RUN\\FME\\snow_events\\snow_events.fmw ^

      --SourceDataset_POSTGRES weatherpost ^

      --SourceDataset_POSTGRES_5 weatherpost ^

      --DestDataset_ARCGISPORTALFEATURES https://maps.gov.yk.ca/portal

Reply