[OCI] Resource Scheduler
![[OCI] Resource Scheduler](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1761299511930%2F63597971-1057-4d13-bb19-5fcb94edc9e4.jpeg&w=3840&q=75)
Ingeniero informático, Oracle ACE, DBA y Arquitecto OCI, con más de 15 años de experiencia en plataformas Oracle. Certificado en OCI Certified Architect Professional y OCI Migration and Integration Certified Professional.
If you prefer to read in Spanish Spanish version.
One of the most important aspects when we are an architect on OCI, it is goes hand in hand with the customer in order to save money when we have to define resources in the tenancy.
Since May 2024, OCI has released the service “OCI resource scheduler“ in order to make us this task easier for us. Before then, this task could be done using methods such as:
Crontab. Nowadays, we always have an environment running every day without interruptions. This environment was ideal for setting up a shell script using cron under the opc user.
Below, you can see an example using this configuration:
[opc ~]$ crontab -l
30 7 * * 1,2,3,4,5 /home/opc/dbsystem/start_dbsystem.sh >> /home/opc/dbsystem/start_dbsystem.log
[opc ~]$ cat /home/opc/dbsystem/start_dbsystem.sh
#!/bin/bash
cd /home/opc/dbsystem
NODE_SWITCH=<OCID>
. ./oci-curl.sh
oci-curl <END_POINT> POST ./empty.json /20160918/dbNodes/${NODE_SWITCH}?action=start
Auto Scaling in OCI by Richard Garsthagen. He published a repository on github under the name OCI-AutoScale (link repositorio) in order to make these operations using tags.
When you set up OCI-AutoScale, one of the step, it’s configurate the tag Schedule:

The next step would be to assign these tags to an instance:

In this example, we have assigned several tags:
Weekend: Shut down all weekend.
WeekDay: Switch on some hours on weekdays. We can see the translation of “0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0” on the left slide.
OCI resource scheduler
These are the steps that we’re going to follow in order to use the Resource Scheduler:

Before getting our hands dirty,we need to check as follows:
Our user has the necessary permissions in order to create schedules.
Allow any-user to manage resource-schedule-family in tenancyThe schedule has the necessary permissions in order to manage resources within the tenancy:
Allow any-user to manage all-resources in compartment '<compartment>' where all{request.principal.type='resourceschedule'}We are going to create a new instance in order to check the new schedule:

After doing all these steps, we are ready. So, let's get down to business!
Let’s go to the section “Governance & Administration” and Schedules:

Here, we can see the Resource scheduler section. Click on “Create a schedule”:

In the first section, we are going to provide the basic information such as name or action.

In the second section, we are going to select the resource on which we want make the action:

Here, we can see a filter with two options: Static or Dynamic.
The differences are as follows:
Static: This is when we define a schedule for a single resource.
Dynamic: This is when we define a schedule for a group of resources. Moreover, when using Dynamic method, the current set of resources that match the criteria is displayed for reference.
Tag: By selecting tag method, you can search for resources using it*.*
Resource Type: You can find resources such as instance, instance pool, autonomous database, function or even DB system.
Compartment: You can locate resources in one compartment or across all compartments*.*
Status: By selecting the status method, you can search for resources using their status. The states are available, running, stopped or all.
In this case, we select the static option and click on our instance:

In the next step, we will be able to add parameters to our resource,but in this case, it does not apply.

The next step is the most important, because we have to define the schedule in order to switch on the instance.

First, we define the schedule using either the “Form Interface” or a “Cron expression”. In this case, since we define a couple of schedules, we will use both options.
Let’s click on “Cron expression” in order to switch on our instance:

Here, we can see as follows:
Recurrence details: A little description, it’s optional except in this case. Watch out! when we use cron, we should fill in this field with a Cron expression.
If you don’t fill in this field, you will see the following error:

Our Cron expression is: “30 12 \ * *“ **.*
Time: UTC time in 24-hour format.
Start date: Enter a date in order to specify the start date.
End date: Enter a date in order to specify the end date, it’s optional.
The last window, it would be a summary our schedule.
Let’s define the schedule in order to switch off our instance. All steps will be the same as in the previous schedule, except when we define the schedule, because we use the option “Form Interface”.
Here’s our schedule:

Ready! With all steps completed, we now have both schedules prepared in order to switch on/switch off our instance.
Moreover, if we go back to the beginning, you will see that both schedules are working.

Looking forward to seeing you in the next article :)
![[26ai] Cleanup of Obsolete PL/SQL Objects](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F64ada612-0048-411c-b9df-61b8825af6e7.png&w=3840&q=75)
![[26ai] Hybrid Read-Only Mode PDB](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F23e8f92e-f89b-4746-930e-98156e3a1ec4.png&w=3840&q=75)
![[26ai] ALERT_LOG_MAX_SIZE](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2Fdad5c53e-425c-4e82-9bbb-e0ccec6e9a4e.jpg&w=3840&q=75)
![[26ai] ConnStr Tool](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F8316641c-ac22-45c3-a59d-4a8a7dfd9de5.png&w=3840&q=75)
![[26ai] Install Oracle AI Database 26ai on Linux 9](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F243000b4-ccef-4cab-97db-f9b47328159f.png&w=3840&q=75)