Creating a Schedule Based Job Definition

Once you have completed your notification settings, we can try setting up a sample schedule-based job definition. Schedule based jobs mean that you are going to run a job definition one or more times on some determinable date and time based pattern. This is done by using a Scheduler trigger and is one of the most used methods for starting jobs. When you need to pick up files from some location on your network, run and deliver some type of report, or perform updates of data in a database, the scheduler is a reliable building block to make these types of processes happen.

To start with creating an example scheduler, look at the manager application. In the navigation panel, it shows you the JobServer.NET machine(s) for which you are connected to. Under each server you can be connected to, you can see a view of the job definitions that are defined on each server. For a new installation, you will just see your connected JobServer.NET machine and no job definitions listed below it.

When you right click on your connected server, you will see a pop-up menu list of options for your server. Select the New Job option from the menu and in the control area will show a new empty job definition form. For the Name field, enter "Cleanup Old Temp Files". Then from the Trigger field a few lines down, select the Scheduler option from the drop-down list.

Once you do, you will see a new dialog open with the options for the scheduler trigger. The first step of course is the only visible option so far, picking a Recurring option. Start off by picking the Once a day option, as the other options are covered in more detail later. The Start Date will default to the current date, so we just want to pick a time of day you want to cleanup some old files. Since JobServer.NET displays times in 24-hour format, pick a time suitable for you. We might recommend entering 23:00 so this job will run an hour before midnight each day. Click the Save button when you are ready.

Now at this point we have started defining this job and when we want it to run. Now we need to tell it what we want it to do. In the bottom section of the job definition, you want to locate and click on the button titled New Step. This will open the new job step dialog. The first field here is the Module field, click here to see the list of installed modules and locate the one called [Files] Find and click on it. This module is used to search for any number of eligible files that meet all the search criteria you might need.

When that has been selected, you should now see the Files Find module has loaded and is now showing all the configuration parameters available. Before we just to that, update the Name field by entering "Find Old Temp Files" into it. Then locate the first parameter call File Source and add a path to a folder on your JobServer.NET machine that contains some old files you no longer want to keep around. For testing, we will use one of the test folders we created above. So, for this example we are putting the folder path of "C:\Temp\JobServer\Cleanup" into the File source parameter. Next, we change the Age threshold type parameter to a value of Older. Then we set Age threshold value to 90. And finally set Age threshold units to Days.

This combination of options tells the Files-Find module that we want to find all files in this folder that are older than 90 days old. So, this step is selecting all the files that we are about to do something with in the next step. We can now finish this step by clicking the Save button and returning to the main job definition.

We now have a job definition with one step defined, which retrieves a list of files. Now we want to do something with that list of files. We do this by adding another step after the first one by again clicking the New Step button. This time when we get the new job step dialog, we want to select the [Files] Delete module. Update the Name field by entering "Delete Old Files" into it. The File source parameter listed here just needs to be connected to the list of files that the previous step has found for us. To do that, select the Assign button on the line for the File source parameter. This is the button that looks like an equal sign. Once you do that, you will see the assignment dialog with a list of all the possible variable and parameter options. You want to locate the one from the FindFiles module in Step 1 with the output parameter of FileList. The FileList parameter name is used by [Files] Find and some other modules to output a list of files that the module has worked on or found in this example.

You can select the FileList output from the [Files] Find module and click the Select button. This now connects the output of [Files] Find to the FileSource input for this module in this step. When a parameter’s value is assigned, you should notice that the value part of the control now changes from an input box to a display showing the linked parameter. When you are ready, you can click the Save button to complete the [Files] Delete step.

Now that you have created this second step, it takes all the files found from the first step and deletes them. This is a good example of how you can clean up folders of old log files and other outdated files you may no longer want to keep around.

Once you click the Save button as the top of the job definition, you will see the job is added to the navigation panel under the server and the job is now active. It will clean up any of the older files it finds in the folder you specified at its scheduled time every day.