You can create lifecycle rules for a bucket based on the last modified time and last access time of objects in the bucket. This way, Object Storage Service (OSS) can regularly convert the storage class of the objects or delete expired objects and parts to save your storage costs.

Background information

A lifecycle rule can include policies based on the last modified time and the last access time at the same time. When you configure lifecycle rules, take note of the following limits:
  • Number of rules

    You can configure up to 100 lifecycle rules in the OSS console. To configure more than 100 lifecycle rules, use OSS SDKs or command-line tool ossutil.

  • Region

    Lifecyle rules based on the last access time can be created for buckets only in the following regions: China (Qingdao), China (Hohhot), Germany (Frankfurt), and Australia (Sydney).

  • Effective time

    After a lifecycle rule is configured, it is loaded within 24 hours and takes effect within 24 hours after it is loaded. Check the configurations of a rule before you save the rule.

For more information about lifecycle rules configured based on the last modified time and the last access time, see Overview.

Procedure

  1. Log on to the OSS console.
  2. Click Buckets, and then click the name of the target bucket.
  3. In the left-side navigation pane, choose Basic Settings > Lifecycle. In the Lifecycle section, click Configure.
  4. If you want to create lifecycle rules based on the last access time of objects, turn on Enable access tracking on the Lifecycle page.
  5. On the page that appears, click Create Rule. In the Create Rule panel, configure the parameters. The following table describes the parameters.
    • Parameters for unversioned buckets
      Section Parameter Description
      Basic Settings Status Specify the state of the lifecycle rule. Valid values: Enabled and Disabled.
      Applied To Specify the objects to which the lifecycle rule applies. If you select Files with Specified Prefix, you can configure multiple lifecycle rules for objects whose names contain different prefixes. If you select Whole Bucket, you can configure only one lifecycle rule for the bucket.
      Prefix Specify the prefix of objects to which the lifecycle rule applies. For example, if you want the rule to apply to objects whose names start with img, enter img in the field.
      Tagging Configure tags. The rule applies only to objects that have specified tags. Example: If you select Files with Specified Prefix and set Prefix to img, Key to a, and Value to 1, the rule applies to all objects that have the img prefix in their names and have the tag a=1. For more information about object tagging, see Configure object tagging.
      Policy for Objects File Lifecycle Configure rules for objects to specify when the objects expire. You can set File Lifecycle to Validity Period (Days), Expiration Date, or Disabled. If you select Disabled, the configurations of File Lifecycle do not take effect.
      Lifecycle-based Rules Configure the policy to convert the storage class of objects or delete expired objects.

      Example 1: Select Last Access Time, set Validity Period (Days) to 30, and specify that the storage class of the objects is converted to IA after the validity period ends. In this case, the storage class of objects whose last access time is September 1, 2021 is converted to Infrequent Access (IA) on October 1, 2021.

      Example 2: Select Last Modified Time, set Expiration Date to September 24, 2021, and specify that objects that are last modified before this date are deleted. In this case, objects that are last modified before September 24, 2021 are automatically deleted. The delete operation cannot be recovered.

      Policy for Parts Part Lifecycle Specify the operations to perform on expired parts. If you select Tagging, this parameter cannot be configured. You can select Validity Period (Days), Expiration Date, or Disabled. If you select Disabled, the configurations of Part Lifecycle do not take effect.
      Notice Each lifecycle rule must contain at least one of object expiration policies and part expiration policies.
      Delete Parts Specify when parts expire based on the value of Part Lifecycle. Expired parts are automatically deleted and cannot be recovered.
    • Parameters for versioned buckets

      Configure the parameters in the Basic Settings and Policy for Parts sections in the same way as the parameters configured for unversioned buckets. The following table describes only the parameters that are different from the parameters configured for buckets that have versioning enabled.

      Section Parameter Description
      Policy for Current Versions Clean Up Delete Marker If you enable versioning for the bucket, you can configure the Clean Up Delete Marker parameter. Other parameters are the same as those you can configure for unversioned buckets.

      After you select Clean Up Delete Marker, if an object has only one version and the version is a delete marker, OSS considers the delete marker expired and cleans up the delete marker. If an object has multiple versions and the current version of the object is a delete marker, OSS retains the delete marker. For more information about delete markers, see Delete marker.

      Policy for Previous Versions File Lifecycle Specify when previous versions expire. Valid values: Validity Period (Days) or Disabled. If you select Disabled, File Lifecycle does not take effect.
      Lifecycle-based Rules Specify the number of days within which objects can be retained after they become previous versions. After they expire, the specified operations are performed on the previous versions the next day. For example, if you set Validity Period (Days) to 30, the storage class of the objects that become previous versions on September 1, 2021 are converted to the specified storage class or deleted on October 1, 2021.
      Notice You can determine when an object becomes a previous version based on the time when the later version is generated.
  6. Click OK.
    After a lifecycle rule is saved, you can view the rule in the lifecycle rule list.