SchedulerX allows you to run scripts on self-managed or cloud-based hosts. This topic shows how to deploy an agent on a host, associate the host with a SchedulerX application, and create a task to run a scheduled shell script on the host.
Prerequisites
-
An available ECS instance or host. For more information, see ECS quick start.
A Java Development Kit (JDK) must be installed on the ECS instance or host to start the agent.
-
The Distributed Task Scheduling service is activated. For more information, see Activate Distributed Task Scheduling.
Ensure that your host and the SchedulerX platform are in the same region.
Background
This example uses an agent to associate a host with SchedulerX and create a scheduled shell script task on the SchedulerX platform. You can also connect to SchedulerX in the following ways:
Overview
Connecting a host to SchedulerX using an agent involves four steps:
-
Associate the host with SchedulerX: Create a new application in SchedulerX and link your host to it.
-
Create a task for the host: Create a task in the console and associate it with the application.
-
Run the task: In the console, select the corresponding instance and run the task.
-
View the results: You can query and analyze the task's execution logs in the console.
Step 1: Associate the host with SchedulerX
1.1 Create an application
-
Log on to the MSE SchedulerX console. In the left-side navigation pane, click Application Management. From the Namespaces drop-down list, select the default namespace, and then click Create Application. Enter an Application Name and Application ID. Set Application Type to General Application and Version to Professional Edition. Configure advanced settings as needed, and then click Next.
Turn on the Log Service switch.
ImportantMake sure that you select the correct region and namespace to ensure that the created resources are accurate.
-
On the Notification Configuration wizard, enter the required information, select a Notification Channels, and set a Notification Contacts to complete the application creation.
1.2 Manually deploy the agent
Download and deploy the agent. For more information, see Manually deploy the agent.
The runtime environment requires JDK 1.8 to 14. If you use a JDK version later than 14, you must remove the -XX:+UseConcMarkSweepGC parameter from the schedulerxAgent/bin/start.sh file in the agent installation directory.
JAVA_OPTS="-Dproject.name=schedulerxAgent -XX:+UseConcMarkSweepGC -XX:+HeapDumpOxxx -XX:HeapDumpPath=${WORKER_LOG_DIR} -XX:+xxx lysis"
if [ -n "${SCHEDULERX_STARTER_MODE}" ]; then
JAVA_OPTS="${JAVA_OPTS} -Dschedulerx.stater.mode=${SCHEDULERX_STARTER_MODE}"
fi
Step 2: Create a task for the host
2.1 Create a task
-
In the left-side navigation pane, click , and then click Add Task.
-
On the Basic configuration wizard page, enter a Name and an Application ID. Set Task Type to Script Task, Scripting Language to shell, and Execute Command to
echo Agent connects to SchedulerX. Select unix for File Format and Run Once for Execution Mode. Configure Advanced Configuration as needed. For more information, see Basic configuration parameters. -
On the Timing configuration wizard, set Time type to cron. Use a generator to create a cron expression. An example expression is 0 * * * * ?, which runs the task once every minute. Configure Advanced Configuration as needed. For more information about the parameters, see Time-based scheduling parameters.
-
On the Notification Configuration wizard, enter the required information, select a Notification Channels, and set a Notification Contacts to complete the task creation. For more information about the parameters, see Notification channels and contacts.
2.2 Verify
In the left-side navigation pane, choose . You can find the created task in the table.
Step 3: Run the task
In the left-side navigation pane, click . Find the task you created, enable it, and click Run once.
Step 4: View the results
-
In the left-side navigation pane, choose . Find the task that you ran and click Log in the Actions column.
-
The log shows the result
Agent connects to SchedulerX, indicating that the shell script task was successfully scheduled and executed.
Related documents
-
For details on creating an application in SchedulerX, see Application Management.
-
For details on connecting to SchedulerX using an agent, see Connect by using an agent (for script or HTTP tasks).
-
For details on creating a task in SchedulerX, see Job Management.
FAQ
-
If you fail to log on to a remote ECS instance, see Log on to a Linux instance by using Workbench.
-
If the wget command times out on an ECS instance when you download the agent, assign a public IP address to the instance or see Upload or download files on a Linux instance.
-
For a summary of frequently asked questions, see Index.