Files
doc-exports/docs/obs/tool-obsutil/obs_11_0021.html
weihongmin1 a41a4e0331 OBS Util 0115 Version
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2026-02-17 10:18:57 +00:00

157 lines
16 KiB
HTML

<a name="obs_11_0021"></a><a name="obs_11_0021"></a>
<h1 class="topictitle1">Deleting an Object</h1>
<div id="body1542943180896"><div class="section" id="obs_11_0021__section1479112110815"><h4 class="sectiontitle">Function</h4><ul id="obs_11_0021__ul104852112012"><li id="obs_11_0021__li148112111014">You can use this command to delete a specified object.</li><li id="obs_11_0021__li94814218018">You can also use this command to delete objects in batches based on a specified object name prefix.<div class="warning" id="obs_11_0021__note2069235414569"><span class="warningtitle"><img src="public_sys-resources/warning_3.0-en-us.png"> </span><div class="warningbody"><p id="obs_11_0021__p156922546561">The delete operation cannot be undone.</p>
</div></div>
</li></ul>
</div>
<div class="section" id="obs_11_0021__section69267287212"><h4 class="sectiontitle">Important Notes</h4><p id="obs_11_0021__p199621934152117">In big data scenarios, parallel file systems usually have deep directory levels and each directory has a large number of files. In such case, deleting directories from parallel file systems may fail due to timeout. To address this problem, you are advised to delete directories in either of the following ways:</p>
<ol id="obs_11_0021__ol241910394217"><li id="obs_11_0021__li19419113913214">On the Hadoop client that has OBSA, an OBS client plugin, embedded, run the <strong id="obs_11_0021__b1366215332450">hadoop fs - rmr obs://{</strong><em id="obs_11_0021__i866283304512">Name of a parallel file system</em><strong id="obs_11_0021__b9662143314455">}/{</strong><em id="obs_11_0021__i126628330455">Directory name</em><strong id="obs_11_0021__b10662133317453">}</strong> command.</li><li id="obs_11_0021__li13438134152113">Configure a lifecycle rule for directories so that they can be deleted in background based on the preset lifecycle rule.</li></ol>
</div>
<div class="section" id="obs_11_0021__section1220752192216"><h4 class="sectiontitle">Command Line Structure</h4><ul id="obs_11_0021__ul2281182518013"><li id="obs_11_0021__li10281142517014">In Windows<ul id="obs_11_0021__ul179971435609"><li id="obs_11_0021__li21937346020">Deleting a single object<pre class="screen" id="obs_11_0021__screen13232122112117">obsutil rm obs://bucket/key [-f] [-versionId=xxx] [-fr] [-o=xxx] [-config=xxx] </pre>
</li><li id="obs_11_0021__li1224416522001">Deleting objects in batches<pre class="screen" id="obs_11_0021__screen113425251415">obsutil rm obs://bucket/[key] -r [-j=1] [-f] [-v] [-o=xxx] [-config=xxx] </pre>
</li></ul>
</li><li id="obs_11_0021__li9116229409">In Linux or macOS<ul id="obs_11_0021__ul1946101412110"><li id="obs_11_0021__li15246140120">Deleting a single object<pre class="screen" id="obs_11_0021__screen18977281317">./obsutil rm obs://bucket/key [-f] [-versionId=xxx] [-fr] [-o=xxx] [-config=xxx] </pre>
</li><li id="obs_11_0021__li952519141419">Deleting objects in batches<pre class="screen" id="obs_11_0021__screen260123212116">./obsutil rm obs://bucket/[key] -r [-j=1] [-f] [-v] [-o=xxx] [-config=xxx] </pre>
</li></ul>
</li></ul>
</div>
<div class="section" id="obs_11_0021__section18901940123814"><h4 class="sectiontitle">Examples</h4><ul id="obs_11_0021__ul5901140173813"><li id="obs_11_0021__li1791174073812">Take the Windows OS as an example. Run the <strong id="obs_11_0021__b457411313143">obsutil rm obs://bucket-test/key -f</strong> command to delete a single object named <strong id="obs_11_0021__b1977114720274">key</strong> in bucket <strong id="obs_11_0021__b22063411284">bucket-test</strong>.<pre class="screen" id="obs_11_0021__screen491194016382"><strong id="obs_11_0021__b691140163811">obsutil rm obs://bucket-test/key -f</strong>
Start at 2024-09-25 04:48:10.1147483 +0000 UTC
Delete object [key] in the bucket [bucket-test] successfully, cost [152], request id [0000016979E1D2B2860BB5181229C72C]</pre>
</li></ul>
<ul id="obs_11_0021__ul1391134012387"><li id="obs_11_0021__li89116406386">Take the Windows OS as an example. Run the <strong id="obs_11_0021__b153291461773">obsutil rm obs://bucket-test -r -f</strong> command to delete all objects in bucket <strong id="obs_11_0021__b12534613192812">bucket-test</strong>.<pre class="screen" id="obs_11_0021__screen1791940163811"><strong id="obs_11_0021__b1691104010383">obsutil rm obs://bucket-test -r -f</strong>
Start at 2024-09-30 08:46:55.5335644 +0000 UTC
[===============================================] 100.00% 21s
Succeed count: 1313 Failed count: 0
Task id: 95936984-f81a-441a-bba0-1fd8254d9241</pre>
</li></ul>
</div>
<ul id="obs_11_0021__ul20705811466"><li id="obs_11_0021__li77051164617">Take the Windows OS as an example. Run the <strong id="obs_11_0021__b152541388407">obsutil rm obs://bucket-test/key -r -f</strong> command to delete all objects and folders prefixed with <strong id="obs_11_0021__b4997141754018">key</strong> in bucket <strong id="obs_11_0021__b1290272618405">bucket-test</strong>.<pre class="screen" id="obs_11_0021__screen67059174618"><strong id="obs_11_0021__b8705114461">obsutil rm obs://bucket-test/key -r -f</strong>
Start at 2024-09-30 08:49:09.5602115 +0000 UTC
[===============================================] 100.00% 21s
Succeed count: 10 Failed count: 0
Task id: 79ab59ec-7e00-4f22-8c88-465faa834125</pre>
</li></ul>
<div class="section" id="obs_11_0021__section6559191102418"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="obs_11_0021__table10831182114445" frame="border" border="1" rules="all"><thead align="left"><tr id="obs_11_0021__row683212154419"><th align="left" class="cellrowborder" valign="top" width="16.31%" id="mcps1.3.6.2.1.4.1.1"><p id="obs_11_0021__p118329219446">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.38%" id="mcps1.3.6.2.1.4.1.2"><p id="obs_11_0021__p15137125919108">Optional or Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="64.31%" id="mcps1.3.6.2.1.4.1.3"><p id="obs_11_0021__p12832121184414">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_11_0021__row108328217449"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p64495172515">bucket</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p154316502519">Mandatory</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p17425512259">The bucket name</p>
</td>
</tr>
<tr id="obs_11_0021__row14181641114718"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p2418114124718">key</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p76483210569">Mandatory for deleting a single object.</p>
<p id="obs_11_0021__p741812412475">Optional for deleting objects in batches.</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p741894118475">The name of the object to be deleted, or the name prefix of the objects to be deleted in batches</p>
<div class="note" id="obs_11_0021__note7180183222110"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="obs_11_0021__p81802321215">If this parameter is left blank when deleting objects in batches, all objects in the bucket are deleted.</p>
</div></div>
</td>
</tr>
<tr id="obs_11_0021__row20170121265812"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p8517143114816">fr</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p1965455113483">Optional for deleting a single object (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p1951718433487">Generates an operation result file when deleting an object.</p>
</td>
</tr>
<tr id="obs_11_0021__row107241436114819"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p5724123684813">f</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p1272453612483">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p972417362487">Runs in force mode.</p>
</td>
</tr>
<tr id="obs_11_0021__row1460034216484"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p560014284815">versionId</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p10600184264818">Optional for deleting a single object (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p56001942134812">The version ID of the object to be deleted.</p>
</td>
</tr>
<tr id="obs_11_0021__row18735850114810"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p3735185044816">r</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p15786145522217">Mandatory for deleting objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p1173519509481">Deletes objects in batches based on a specified object name prefix.</p>
<div class="caution" id="obs_11_0021__note12480614112414"><span class="cautiontitle"> CAUTION: </span><div class="cautionbody"><p id="obs_11_0021__p19480414202414">When you batch delete objects, all objects with the specified prefix will be deleted.</p>
</div></div>
</td>
</tr>
<tr id="obs_11_0021__row015935193510"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p3662204585313">j</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p19305175612615">Optional for deleting objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p17665114555311">The maximum number of concurrent tasks for deleting objects in batches. The default value is the value of <strong id="obs_11_0021__b1268754012466">defaultJobs</strong> in the configuration file.</p>
<div class="note" id="obs_11_0021__note891964620819"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="obs_11_0021__p1091964618820">The value is ensured to be greater than or equal to 1.</p>
</div></div>
</td>
</tr>
<tr id="obs_11_0021__row198551816104916"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p20856121619492">v</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p3791455132212">Optional for deleting objects in batches (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p1385671610497">Deletes versions of an object and the delete markers in batches based on a specified object name prefix.</p>
</td>
</tr>
<tr id="obs_11_0021__row106825331499"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p268213314499">o</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p1979414554228">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p10682123310498">The folder that stores the result files. After the command is executed, result files (possibly success and failure files) will be created in the specified folder. The default value is <strong id="obs_11_0021__b2095215720228">.obsutil_output</strong>, a subfolder in the user's home directory where obsutil commands are executed.</p>
<div class="note" id="obs_11_0021__note236970182510"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="obs_11_0021__ul101190347408"><li id="obs_11_0021__li111993418408">A result file should be named as follows: <strong id="obs_11_0021__b9923175232616">rm_{succeed | failed}_report_</strong><em id="obs_11_0021__i17925205219267">time</em><strong id="obs_11_0021__b392511527263">_TaskId.txt</strong>.</li><li id="obs_11_0021__li412103664016">By default, the maximum size of a single result file is 30 MB and the maximum number of result files that can be retained is 1,024. You can set the maximum size and number by configuring <strong id="obs_11_0021__b12844164362715">recordMaxLogSize</strong> and <strong id="obs_11_0021__b15845134315278">recordBackups</strong> in the configuration file.</li><li id="obs_11_0021__li1850124514459">If there are multiple folders and files and you need to confirm the details of a failed task, refer to the failure result file <strong id="obs_11_0021__obs_11_0013_b5396121718320">cp_failed_report_</strong><em id="obs_11_0021__obs_11_0013_i1639621714325">time</em><strong id="obs_11_0021__obs_11_0013_b1739631753215">_</strong><em id="obs_11_0021__obs_11_0013_i203979172328">TaskId</em><strong id="obs_11_0021__obs_11_0013_b1639718176326">.txt</strong> in the result folder and the <a href="obs_11_0056.html">log files</a> in the log path.</li></ul>
</div></div>
</td>
</tr>
<tr id="obs_11_0021__row17841354151810"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p114391014518">bucket-cname</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p4143210950">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p16143610251">The user-defined domain name bound to the bucket</p>
<div class="note" id="obs_11_0021__note16256574591"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="obs_11_0021__p172595719595">This parameter is only supported by obsutil 5.7.9 and later.</p>
</div></div>
</td>
</tr>
<tr id="obs_11_0021__row083396143714"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p153951131317">config</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p12395135316">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__obs_11_0008_p1750111452317">The user-defined configuration file for executing the current command. For details about parameters that can be configured, see <a href="obs_11_0035.html">Configuration Parameters</a>.</p>
</td>
</tr>
<tr id="obs_11_0021__row7885842173413"><td class="cellrowborder" valign="top" width="16.31%" headers="mcps1.3.6.2.1.4.1.1 "><p id="obs_11_0021__p1966666191820">payer</p>
</td>
<td class="cellrowborder" valign="top" width="19.38%" headers="mcps1.3.6.2.1.4.1.2 "><p id="obs_11_0021__p1266611611820">Optional (additional parameter)</p>
</td>
<td class="cellrowborder" valign="top" width="64.31%" headers="mcps1.3.6.2.1.4.1.3 "><p id="obs_11_0021__p1166617619181">Specifies that requester pays is enabled.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="obs_11_0021__section6926520122416"><h4 class="sectiontitle">Response</h4><p id="obs_11_0021__p21251255183018">Refer to <a href="obs_11_0013.html#obs_11_0013__section6926520122416">Response</a> for uploading an object.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0012.html">Object Commands</a></div>
</div>
</div>