Page History
...
- File Watching is about watching for incoming files from a directory, see JS7 - How To - File Watching.
- Directory Watching is about watching for changes to a directory, see JS7 - How To - Directory Watching
Configuring Directory Watching
Find a sample implementation from the following chapters.
...
- PowerShell is available for Windows servers by default.
- Consider the shebang in the first line of the job that indicates the PowerShell version in use:
- the string
@@findstr/v "^@@f.*&" "%~f0"|powershell.exe -&goto:eof
indicates use ofpowershell.exe
from version 5.1. - the string
@@findstr/v "^@@f.*&" "%~f0"|pwsh.exe -&goto:eof
indicates use ofpwsh.exe
from version 6 or 7.
- the string
- Consider the shebang in the first line of the job that indicates the PowerShell version in use:
- PowerShell can be installed for Unix environments such as Linux and MacOS.
- Consider to modify the shebang in the first line of the job like this:
- the string
#!/usr/bin/env pwsh
can be used assuming thatpwsh
is the binary of the PowerShell interpreter.
- the string
- Consider to modify the shebang in the first line of the job like this:
Running the Workflow
Adding an Order
In the Workflows view users can add an order to the Directory Watching workflow:
- The workflow's action menu offers the "Add Order" operation.
- Alternatively the icon can be used to add an order.
Adding an order brings up the following popup window:
- The popup window displays the list of required workflow variables. An order can be added only after values for required variables are specified.
- Workflow variables equipped with a default value can be changed when clicking the Modify Variables link.
When clicking the Modify Variables link the following popup window is displayed:
- The popup window allows to specify values for all variables declared with the workflow.
Monitoring Execution
When the order is added it will be displayed in the Workflows view
- from a green bullet indicting the job that is executed.
- from the History panel the Order ID is visible that can be clicked to open the order's log view window.
Viewing the Order Log
The order log view window displays
- information about the start time and the Agent used to execute the workflow,
- information about workflow variables,
- any output created by the job,
- the contents of the monitor log that holds registered events.
Backup
Job Source Code
Find the full source code of the job:
...
- The implemenation makes use of the
- .Net FileSystemWatcher class
- PowerShell Register-ObjectEvent cmdlet
- Lines 7 - 11: creates the FileSystemWatcher object
- Lines 14 - 33: hold the script block to move files in case of events indicating creation of a file.
- Lines 36 -38: hold the script block to log events in case of events not related to creation of a file.
- Lines 41 - 44: subscribe to the related events and assign the respective script block
- Lines 58 - 68: loops for the given period and interrupts in intervals to check for changes to the monitor log file.
- Lines 71 - 72: unsubscribes from registered events and destroys the FileSystemWatcher object.
Overview
Content Tools