To configure lifecycle rules based on the last access time of objects to automatically monitor the access mode of objects in a bucket, identify cold data, and then convert the storage class of the cold data to reduce storage costs, run the access-monitor command to enable access tracking for the bucket.
This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the specific binary name. For more information, see Get started with ossutil.
Only ossutil 1.7.15 and later support the access-monitor command.
Configure access tracking
Command syntax
./ossutil64 access-monitor --method put oss://bucketname/ local_xml_file
The following table describes the parameters in the preceding command.
Parameter
Description
bucketname
The name of the bucket for which you want to configure access tracking.
local_xml_file
The name of the local file that is used to configure access tracking. Example:
config.xml
.Examples
Enable or disable access tracking by using a local XML file.
Enable access tracking
<?xml version="1.0" encoding="UTF-8"?> <AccessMonitorConfiguration> <Status>Enabled</Status> </AccessMonitorConfiguration>
Disable access tracking
<?xml version="1.0" encoding="UTF-8"?> <AccessMonitorConfiguration> <Status>Disabled</Status> </AccessMonitorConfiguration>
The following sample code provides an example on how to configure access tracking for a bucket named examplebucket:
./ossutil64 access-monitor --method put oss://examplebucket/ config.xml
The following output is returned:
0.299514(s) elapsed
Query access tracking configurations
Command syntax
./ossutil64 access-monitor --method get oss://bucketname [local_xml_file]
The following table describes the parameters in the preceding command.
Parameter
Description
bucketname
The name of the bucket whose access tracking configurations you want to query.
local_xml_file
The name of the local file that is used to store access tracking configurations. Example:
local.xml
. If this parameter is not specified, the status of access tracking is displayed.Examples
The following sample code provides an example on how to query the access tracking status of a bucket named examplebucket and display the status:
./ossutil64 access-monitor --method get oss://examplebucket
The following output is returned:
<?xml version="1.0" encoding="UTF-8"?> <AccessMonitorConfiguration> <Status>Enabled</Status> </AccessMonitorConfiguration> 0.154689(s) elapsed
The following sample code provides an example on how to query the access tracking status of a bucket named examplebucket and store the status in the local.xml file:
./ossutil64 access-monitor --method get oss://examplebucket/ local.xml
The following output is returned:
The following result is displayed:
0.214483(s) elapsed
The local.xml file contains the following content:
<?xml version="1.0" encoding="UTF-8"?> <AccessMonitorConfiguration> <Status>Enabled</Status> </AccessMonitorConfiguration>
What to do next
After access tracking is enabled, you need to configure lifecycle rules based on the last access time of objects to convert the storage class of cold data. This reduces storage costs. For more information, see Lifecycle.