lifecycle - Get or set lifecycle configuration for a bucket


gsutil lifecycle get url
gsutil lifecycle set config-json-file url...


The lifecycle command can be used to get or set lifecycle management policies for the given bucket(s). This command is supported for buckets only, not objects. For more information on object lifecycle management, please see the Cloud Storage docs.

The lifecycle command has two sub-commands:


Gets the lifecycle configuration for a given bucket. You can get the lifecycle configuration for only one bucket at a time. The output can be redirected into a file, edited and then updated via the set sub-command.


Sets the lifecycle configuration on one or more buckets. The config-json-file specified on the command line should be a path to a local file containing the lifecycle configuration JSON document.


The following lifecycle configuration JSON document specifies that all objects in this bucket that are more than 365 days old will be deleted automatically:

      "action": {"type": "Delete"},
      "condition": {"age": 365}

The following (empty) lifecycle configuration JSON document removes all lifecycle configuration for a bucket: