Created
June 24, 2024 09:39
-
-
Save jeansymolanza/020ada704090884f6cc910cb77b5af1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if correct number of arguments are provided | |
if [ $# -ne 2 ]; then | |
echo "Usage: $0 <job_name> <desired_state>" | |
exit 1 | |
fi | |
# Assign command line arguments to variables | |
job_name=$1 | |
desired_state=$2 | |
# Get current job status | |
current_state=$(autorep -J $job_name | grep "Status:" | awk '{print $2}') | |
# Check if the job exists | |
if [ -z "$current_state" ]; then | |
echo "Error: Job $job_name not found" | |
exit 1 | |
fi | |
# Compare current state with desired state | |
if [ "$current_state" != "$desired_state" ]; then | |
echo "Current state ($current_state) does not match desired state ($desired_state)" | |
echo "Sending event to update job state..." | |
sendevent -E CHANGE_STATUS -J $job_name -s $desired_state | |
echo "Event sent. New state should be $desired_state" | |
else | |
echo "Job $job_name is already in the desired state ($desired_state)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment