Ping server every 30 seconds

Suppose that for some reason the connectivity between machine running Automation Workshop and some other machine (server) has to be maintained at all times. In case the connection can not be established, it is necessary to notify the administrator as soon as possible.

Solution: use Task Scheduler to periodically launch an Action, which is configured to ping the server and send an email to specified address when not receiving server reply.

How to periodically ping IP address of the server? The creation of Task can be divided in three simple parts. First, a new Task has to be created. Second, you will need to add and configure the Task Scheduler Trigger, the function of which is to periodically execute the Task. Third, you will need to setup the Action that will ping the server whenever the Task is triggered by Task Scheduler.

How to create a new Task? Creating a new Task in Automation Workshop is very easy. Open Febooti Automation Workshop manager by clicking on Febooti Automation Workshop program icon in Start menu. Then create a new Task by in one of the following ways:

  • Click on File section of main menu and select the New task… option.
  • Click right mouse button within Task pane and choose New task… option from context menu.
  • Push Ctrl+N keyboard shortcut when Automation Workshop manager window is active.

Either way, the Task Wizard will be opened to provide step-by-step assistance in configuring the Task.

How to add the Task Scheduler trigger to the Task?

  1. Go to the Triggers tab (after the Welcome screen), where it allows adding Triggers to the Task.
  2. Click the Add… button and a list of available Triggers will be opened.
  3. Choose the Task Scheduler trigger and click OK. The Task Scheduler properties will be opened.

How to configure Task Scheduler trigger to periodically start the Task? Let us suppose that for our goals it is sufficient to ping the server once per every 30 seconds. As you can see, by default Task Scheduler offers to create a Task which is scheduled daily at the same time. What we need, is to change schedule type from daily to seconds. Set appropriate Start date and configure Task Scheduler to Recur every 30 seconds.

Task Scheduler: recur every 30 seconds

If the Task is to be run continuously without any exceptions on particular time, days of the week, dates or months, the Task Scheduler is already configured. Click OK and you will see the Task Scheduler trigger appear in Trigger list of Task Wizard. Click Next to proceed with setting up the Action.

How to add an Action to ping the server periodically? An Action is added in the same way as Trigger, just click the Add… button when in the Action tab of Task Wizard. Automation Workshop does not feature a built-in ping command, however it is very efficient for running external commands. In this case, we will use an Action that can run command line applications. Open Run category, select Run DOS / Cmd Command Action and click OK.

How to configure an Action to ping the server periodically? We need to tell Run DOS / Cmd Command Action to run the PING command to ping the particular IP address. For the sake of example, let us suppose that server's IP address is Write the ping -n 1 into a Command line input (on Command tab of Run DOS / Cmd command Action).

Ping specified server from command line: ping -n1

-n 1 parameter means that only one data packet will be sent per time to ensure server connectivity. If connection is somewhat unstable, you might want to increase the number of data packets sent each time. Note that you will have to substitute with the actual server IP address (or URL name if available).

How to detect failed ping request and automatically send error report? So far the Task is set to ping the server every 30 seconds. However, we also need to setup error reporting which will occur whenever the server fails to respond to ping request. When the ping command manages to get through and receives server reply, its errorlevel is set to 0 (which means successful completion). If not, the errorlevel of ping command will differ from 0.

DOS / Cmd command - Treat error levels greater than 0 as error

Run DOS / Cmd Command Action can process returned errorlevels. In this case, we will need to set the option to Treat error levels greater than 0 as error. Which means that anything but completely successful ping will be treated as error. Note that Wait for command to complete / terminate must be selected in order for Run DOS / Cmd Command to wait for the results of ping command before finishing the Task.

How to send email with error report when the Action experiences an error? After setting up periodical pinging and treating non-zero (non-success) errorlevels as errors, we need to tell Action what actually to do when experiencing an error. Switch to the On Error tab of Run DOS / Cmd Command properties, check the Send email when this Action encounters an error checkbox and provide the email address of sender (From field) and recipient (To field) that will be used when sending error notifaction email.

Send email when ping encounters an error

Click OK and the Action will be saved. Essentially, the Task is ready. You might want to check other options for additional configuration, if necessary, but normally the Task will become active as soon as created (and begin pinging starting from the date and time specified in Task Scheduler settings).

Note that during server downtime, an email will be generated every 30 seconds which can lead to large amount of sent emails during somewhat longer downtime. Also, in order to maintain comprehensiveness of the log file when running frequently recurring Tasks, you might consider choosing Log only Task errors and warnings in the Log tab of Task properties.

The Task described in this tutorial might be insufficient to grant complete connectivity check. For more comprehensive approach, you might want to:

  1. Perform tracert command and trace route to server and gateway / router.
  2. Ping DNS to check whether it is working properly.
  3. Save the information returned by tracert and ping commands into report.txt file for later reviewing. Depending on the situation, executing media player that plays an audible alarm can also prove really useful.

This tutorial is rather intended to show how to configure Task Scheduler to execute Task with specified intervals as well as how to add Actions and process its errors in automatic manner.

Free trial 15 day trial · Details…
Buy now 30 day MBG · Details…

If you have any questions, please do not hesitate to contact our support team.

© 2001–2019 Febooti Ltd.