Thursday 29 August 2024

AutoSys: How to Set and Cancel Future Events

 AutoSys: How to Set and Cancel Future Events

autosys



AutoSys is a powerful job scheduling tool that allows users to automate and manage complex workflows across different systems. One of its advanced features is the ability to set and cancel future events, which can be crucial for managing time-sensitive tasks or adjusting schedules on the fly. This article will explain how to set future events using the sendevent command and how to cancel events that have been scheduled.

Setting Future Events in AutoSys

In AutoSys, you can use the sendevent command to trigger events for jobs. These events can be immediate or scheduled for a future time. Setting a future event allows you to automate the start, stop, or change of a job’s state at a specified time, which is particularly useful for managing workflows that need to occur outside of normal working hours or in response to specific triggers.

Common Future Events You Can Set

  1. STARTJOB
    • Schedules a job to start at a future time.
  2. KILLJOB
    • Schedules a job to be killed or terminated at a future time.
  3. CHANGE_STATUS
    • Schedules a change in the job's status, such as putting a job on hold or taking it off hold.
  4. DELETEJOB
    • Schedules the deletion of a job at a future time.

How to Set a Future Event

The sendevent command is used to schedule these events. The basic syntax for setting a future event is as follows:


sendevent -E EVENT_NAME -J job_name -T "MM/DD/YY HH:MM:SS"
  • -E EVENT_NAME: Specifies the type of event (e.g., STARTJOB, KILLJOB).
  • -J job_name: Specifies the name of the job for which the event is scheduled.
  • -T "MM/DD/YY HH:MM:SS": Specifies the date and time when the event should occur.

Example 1: Scheduling a Job to Start in the Future

Suppose you have a job named daily_backup that you want to start at 11:30 PM on September 1, 2024. You would use the following command:


sendevent -E STARTJOB -J daily_backup -T "09/01/24 23:30:00"

This command tells AutoSys to start the daily_backup job at the specified date and time.

Example 2: Scheduling a Job to be Killed in the Future

If you need to terminate a job named data_import at 2:00 AM on September 2, 2024, you would use:


sendevent -E KILLJOB -J data_import -T "09/02/24 02:00:00"

This will ensure that the data_import job is terminated at the designated time.

Canceling Future Events in AutoSys

Once you have scheduled a future event, there may be times when you need to cancel it. AutoSys allows you to cancel these events using the sendevent command with the -E CANCELJOB option.

How to Cancel a Future Event

To cancel a scheduled event, you need to know the job name and the type of event that was scheduled. The basic syntax for canceling an event is:


sendevent -E CANCELJOB -J job_name

Example 1: Canceling a Future STARTJOB Event

If you previously scheduled a job named daily_backup to start in the future and now need to cancel that event, you would use:


sendevent -E CANCELJOB -J daily_backup

This command cancels any scheduled STARTJOB events for daily_backup.

Example 2: Canceling a Future KILLJOB Event

Similarly, if you scheduled a KILLJOB event for the data_import job but need to cancel it, you would run:


sendevent -E CANCELJOB -J data_import

This will cancel any pending KILLJOB events for data_import.

Important Considerations

  1. Timing

    • Ensure that the time zone settings in AutoSys are correct and consistent with the time zone of the target system when scheduling future events.
  2. Event Conflicts

    • If you schedule conflicting events (e.g., scheduling a STARTJOB and KILLJOB at the same time), AutoSys will process them in the order they were scheduled.
  3. Checking Event Status

    • After scheduling or canceling an event, it's a good practice to verify the status of the job using AutoSys commands like autorep to ensure that the events were successfully processed.
  4. Script Automation

    • You can include sendevent commands in scripts to automate the scheduling and canceling of events, which is particularly useful for complex workflows that require dynamic adjustments.

Conclusion

Setting and canceling future events in AutoSys is a powerful feature that enables precise control over job scheduling and execution. By using the sendevent command, you can automate job starts, stops, and status changes at specific times, ensuring that your workflows run smoothly and efficiently. Understanding how to manage these events allows you to respond quickly to changing business needs and maintain the flexibility required in modern IT environments.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.