Trigger Jobs to Watch Files on Linux

Follow

It is possible to use JAMS Triggers to monitor for a file on a remote Linux node and execute a Job based on a file event. Below is an example of a Trigger and Job that looks for a file and deletes it when it is present.

 
Creating the Job
To start, pick the Folder you'd like to create a new Job within. Name it something such as "DeleteFileLinux." Choose the Execution Method SSHAgent.

Proceed to enter an email address. The Username chosen here should be the one that connects to the Linux node. For the source, enter this:


#!/bin/bash

rm /home/kevin/rogue_file

 

Be sure to make the file path relevant to the Linux system. This will be the same file that is monitored in the next step.
 
After manipulating any other Job Properties, toggle the Checkbox to edit the Job Definition after adding. Next, open the Properties Tab and go to the Submit Options section and set the Username and Agent Node Name for the Linux node. Click the Save button to finish.

Creating the Trigger
Now, open the Triggers Tab within your Folder and create a new Trigger; name it something such as "Delete Rogue File".  

Click next to add a Trigger Event. Click the Add button and click File Event. For File Name, choose the same file that was chosen when the job to that deletes a file was created. Also choose the same Agent node and Username. Click the Save button.

Click Next to add an Action, and click the Add button and then Submit Job. Click the ".." to choose the DeleteFileLinux job. Click the Save button. Proceed and click Finish.

Now, whenever there is a file named /home/kevin/rogue_file on the remote note 192.168.1.32, JAMS will execute the job DeleteFileLinux on this remote node, which will delete rogue_file.
 
There are many possibilities with the combination of triggers and jobs; this example shows one way that they can be utilized.
Have more questions? Submit a request

Comments