Running commands on a schedule

system

Introduction

This article will show a simple example of running a command on the underlying OS according to a schedule and then emailing that file as an attachment.

The example used here will be to set up a daily task which will gzip the current web server access log and then email that file out.

 

Creating an Automation

1. In the admin web UI, navigate to Automations and click Create.

2. Give the automation a Name, which here will be Tar Hypersocket Log.

3. For the Task, start typing execute, then select Execute Local Command from the list that appears.

4. In the Executable field set tar.

5. In the Arguments field enter each of the following as it's own entry:
-cPzf
/tmp/hypersocket-idm.log.tgz
/var/log/hypersocket-idm/hypersocket-idm.log

 

6. Click on the Schedule tab. This will be a nightly task, so in the At field, type in 00:00. We can leave the other fields blank. 

7. Click on the Repeat tab. Change Repeat to DAYS and set Every to 1.

8. Click Create to make the automation.

 

 

Deliver the file via email

1. Click the newly created automation to see the automation flow and click the Plus icon.

 

2. Name the new automation Email Hypersocket Log. The Event will already be filled out as we have chained this to the gzip automation. Leave Triggers On as Success and enter Send Email as the Triggers Task

 

3. We can leave Conditions blank, but click on the Plain Message tab and set a Subject and Email.

4. With the addition of the LogonBox Cloud Messaging Service a new Provider option has been added. This allows the choice of using the already configured option in the System Configuration, the Cloud Messaging Service, or to use SMTP options configured in the Message Settings page. Note that in this example we need to set the SMTP option as the Cloud Messaging Service does not support the ability to send attachements in the messages.

 

 

5. Now go to the Delivery tab and enter the email address the file should be delivered to.


6. Finally go to the Attachments tab and enter the output file's patch, in this case /tmp/hypersocket-idm.log.tgz into the File Paths.

 

6. Click Create to complete the automation creation.

 

Testing

1. You can click the Other Actions icon and the Run Now to run it immediately.

 

2. Once the test is run you can navigate to the Audit Log and can see that both commands were executed successfully.