SAP Housekeeping (logs / traces / spool / jobs / filesystem)
Two layers: ABAP-side reorg jobs (the correct, retention-aware way — §1) and OS-side file cleanup
(§3, for what the jobs don't cover). DB log/trace cleanup is delegated to
sap-db-command-reference (§6).
Guardrail — deletion is destructive and sometimes compliance-bound.
Identify SID/host → classify PRD → preview what will be deleted and how far back → confirm (typed
for PRD) → delete → verify. Specific hazards, do NOT skip:
- Audit logs are often legally required — check retention with security/auditors before deleting (§4).
- Never delete DB logs/archives that aren't backed up — data-loss risk (§6).
- Prefer the standard reorg jobs (they honour configured retention) over manual
rm.
- Never
rm a live trace of a running instance.
1. The standard reorganization jobs (the right way) — SAP Note 16083 [G, K1]
Schedule these in SM36 ("Standard jobs" button auto-creates them). They delete by age/retention,
not blindly. ABAP-side, so OS-independent.
| Job name |
Report |
Cleans |
Frequency |
SAP_REORG_JOBS |
RSBTCDEL2 |
old background job logs (SM37) |
daily |
SAP_REORG_SPOOL |
RSPO1041 (improved RSPO0041) |
old spool requests (SP01) |
daily |
SAP_REORG_ABAPDUMPS |
RSSNAPDL |
old ABAP short dumps (ST22) |
daily |
SAP_REORG_BATCHINPUT |
RSBDCREO |
old batch-input sessions (SM35) |
daily |
SAP_REORG_JOBSTATISTIC |
RSBPSTDE |
old job statistics |
monthly |
SAP_REORG_UPDATERECORDS |
RSM13002 |
old update records (SM13) |
daily |
SAP_COLLECTOR_FOR_PERFMONITOR |
RSCOLL00 |
collects/reorgs performance stats (ST03) |
hourly |
SAP_REORG_XMILOG |
RSXMILOGREORG |
external management interface log |
weekly/monthly |
RSBTCDEL2: run by the batch administrator → reorganizes all clients; otherwise current client
only. [K1]
RSPO1041: set the retention/age in its variant. Also run spool/TemSe consistency regularly:
RSPO1043 (spool) and the TemSe check (SP12 / SAP Notes 48400, 130978). [K2]
2. Spool & TemSe consistency
SP12 → TemSe consistency check & reorg (temporary sequential objects)
RSPO1043 → spool consistency check
Inconsistent TemSe/spool is a common cause of a spool filesystem/table growing despite RSPO1041. [K2]
3. OS-level cleanup — the instance work directory
Work directory: /usr/sap/<SID>/<INST><nr>/work/ (Windows: …\work\). Safe-to-remove candidates when a
filesystem is filling, oldest first, and never the currently-active file: [G, K4]
| Pattern |
What it is |
Safe to delete? |
*.OLD |
previous traces, re-created on each restart |
✅ yes |
core, core.<pid> |
crash core dumps |
✅ after capturing for analysis |
old dev_w*, dev_rfc*, dev_rd |
rotated work-process/RFC/gateway traces |
✅ old ones; not the active |
stderr<n> |
per-start stdout/stderr |
✅ old ones |
dev_disp, dev_ms, dev_icm (current) |
live dispatcher/msg/ICM traces |
⚠️ reset via SM50/SMGW, don't rm while running |
Reset traces cleanly from the app rather than deleting the active file: SM50 (work process traces),
SMGW (gateway). Also check /sapmnt/<SID>/global for old WF_LOG_* workflow files.
4. Security audit log ⚠️ retention/compliance
Audit log files (*.AUD) under /usr/sap/<SID>/<INST><nr>/log/ (SM19/RSAU config, SM20 view). Delete
via SM18 (or a scheduled reorg), not blind rm: [G, K3]
SM18 → reorganize/delete audit logs older than <retention>
Confirm the retention requirement with security/audit/compliance before deleting audit logs. These
are frequently required to be kept for a mandated period. This is the one cleanup that can create a
compliance incident.
5. Orphaned IPC / shared memory (cleanipc)
After an instance crash, orphaned shared-memory/semaphore segments can block a restart. Clean them (UNIX):
cleanipc <nr> remove # remove IPC resources of instance <nr> ⚠️ only when the instance is DOWN
Run only when that instance is stopped — it wipes the instance's shared memory. [G, K4]
6. Database logs/traces → delegate
DB transaction/redo/archive logs and DB traces are cleaned with DB tools, not rm, and only after a
successful backup:
- see sap-db-command-reference per
dbms_type;
- e.g. Oracle archived redo via
brarchive -sd (after backup), Db2 archived logs, HANA log segments +
backup-catalog housekeeping.
Never delete an un-backed-up transaction log — it breaks point-in-time recovery. [G]
7. "Filesystem full" quick triage
df -h # which FS: /usr/sap, /sapmnt, DB data, DB log, /oracle, /hana
du -sh /usr/sap/<SID>/<INST><nr>/work/* | sort -h | tail # biggest offenders in work/
Then: §3 (work dir) for /usr/sap; §6 (DB, after backup) for the DB/log filesystems; §1 (reorg jobs) so
it doesn't refill. Cross-ref sap-health-triage — full FS is its #1
"won't start / hung" cause.
Cross-references
Run as the correct OS user
Identify the right OS user before running anything, and switch with a login shell. Wrong-user
execution is a top cause of SAP failures, and the damage outlives the command: files created by root
under /usr/sap, /sapmnt or a DB directory break every later start by the real owner. A login shell
also matters because each user carries the environment the tools need (SAPSYSTEMNAME, ORACLE_HOME/
ORACLE_SID, SYBASE, DB2INSTANCE, library paths) — without it, commands fail or act on the wrong system.
| What you're operating |
UNIX user |
Windows |
SAP instances — sapcontrol, startsap/stopsap, tp, R3trans, disp+work, sappfpar, cleanipc |
<sid>adm (lower-case SAP SID) |
<SID>adm; services run as SAPService<SID> |
SAP HANA — HDB, hdbsql, hdbnsutil |
<sid>adm of the HANA SID (e.g. h10adm — may differ from the SAP SID) |
n/a (HANA server is Linux-only) |
Oracle — sqlplus, lsnrctl, BR*Tools |
ora<dbsid> (BR*Tools also runs as <sid>adm; generic installs may use oracle) |
<SID>adm; DB runs as a service |
SAP ASE — isql, startserver, Backup Server |
syb<dbsid> |
syb<dbsid> / SAPService<SID> |
IBM Db2 — db2start/db2stop, db2 CLP |
db2<dbsid> (the instance owner = DB2INSTANCE) |
same; Db2 runs as a service |
SAP MaxDB / liveCache — dbmcli, x_server |
sdb (software owner, group sdba) + a DBM operator at DB level |
install/service account |
MS SQL Server — sqlcmd, service control |
n/a (Windows-only for SAP) |
<SID>adm / the SQL Server service account |
SAP Host Agent — saphostexec, saphostctrl |
root |
Administrator / SAPHostExec service |
Rules
- Switch with a login shell:
su - <user> (the - is what loads the environment) or sudo -iu <user>.
Windows: use the correct account, or an elevated shell only where documented.
root only where the procedure explicitly says so — e.g. saproot.sh after a kernel extract, SAP Host
Agent install/upgrade. Never as a shortcut around a permission error; that is how root-owned files get
created and break the system later.
- Verify before acting:
whoami / id, plus the env actually being set (echo $SAPSYSTEMNAME,
echo $ORACLE_SID, echo $DB2INSTANCE, echo $SYBASE).
- State the user in every command you hand over (e.g. "as
<sid>adm:"), and if the required user is not
available, say so and stop — do not substitute another user.
Staying current — check SAP Notes first
SAP Notes supersede this file. Landscapes differ by release, patch level, DB and OS, and SAP changes
procedures via Notes/KBAs between doc revisions.
If the SAP Notes MCP is configured, use it before
acting on anything version-specific — especially any destructive step, or when a command here doesn't
behave as documented:
search the topic (e.g. the component + symptom, or a Note number cited below).
fetch the promising Note IDs for the current text, validity (affected releases/components),
prerequisites and side effects.
- Prefer the Note over this file where they disagree, and say which Note you followed.
No MCP available? Look the Note up on me.sap.com/notes/<id> and say the check was skipped rather than
assuming this file is current.
Sources
To confirm/deepen — check current SAP Notes with the SAP Notes MCP (search, then fetch the note ID): SAP Note 16083 for the full current
job list + report variants, and Note 48400 for the TemSe/spool consistency procedure.
1---2name: sap-housekeeping3description: Keep a SAP NetWeaver / S/4HANA system's logs, traces, spool, job logs, ABAP dumps, audit logs and work directory from filling the filesystem — via the SAP standard reorganization jobs (RSBTCDEL2, RSPO1041, RSSNAPDL, RSBDCREO …) and safe OS-level cleanup, on Linux/Windows/AIX. Use for "clean up logs/traces", "/usr/sap is full", "reorg spool/jobs/dumps", "housekeeping jobs", "delete old work-dir files", "audit log cleanup". Hands DB log/trace cleanup to sap-db-command-reference. Cited to SAP Note 16083 + help.sap.com.4---56# SAP Housekeeping (logs / traces / spool / jobs / filesystem)78Two layers: **ABAP-side reorg jobs** (the correct, retention-aware way — §1) and **OS-side file cleanup**9(§3, for what the jobs don't cover). DB log/trace cleanup is delegated to10[sap-db-command-reference](../sap-db-command-reference/SKILL.md) (§6).1112> **Guardrail — deletion is destructive and sometimes compliance-bound.**13> Identify SID/host → classify PRD → **preview what will be deleted and how far back** → confirm (typed14> for PRD) → delete → verify. Specific hazards, do NOT skip:15> - **Audit logs are often legally required** — check retention with security/auditors before deleting (§4).16> - **Never delete DB logs/archives that aren't backed up** — data-loss risk (§6).17> - **Prefer the standard reorg jobs** (they honour configured retention) over manual `rm`.18> - Never `rm` a **live** trace of a running instance.1920---2122## 1. The standard reorganization jobs (the right way) — SAP Note 16083 [G, K1]2324Schedule these in **SM36** ("Standard jobs" button auto-creates them). They delete by **age/retention**,25not blindly. ABAP-side, so OS-independent.2627| Job name | Report | Cleans | Frequency |28|----------|--------|--------|-----------|29| `SAP_REORG_JOBS` | `RSBTCDEL2` | old background **job logs** (SM37) | daily |30| `SAP_REORG_SPOOL` | `RSPO1041` (improved `RSPO0041`) | old **spool** requests (SP01) | daily |31| `SAP_REORG_ABAPDUMPS` | `RSSNAPDL` | old **ABAP short dumps** (ST22) | daily |32| `SAP_REORG_BATCHINPUT` | `RSBDCREO` | old **batch-input** sessions (SM35) | daily |33| `SAP_REORG_JOBSTATISTIC` | `RSBPSTDE` | old job **statistics** | monthly |34| `SAP_REORG_UPDATERECORDS` | `RSM13002` | old **update** records (SM13) | daily |35| `SAP_COLLECTOR_FOR_PERFMONITOR` | `RSCOLL00` | collects/reorgs performance stats (ST03) | hourly |36| `SAP_REORG_XMILOG` | `RSXMILOGREORG` | external management interface log | weekly/monthly |3738- `RSBTCDEL2`: run by the **batch administrator** → reorganizes **all** clients; otherwise current client39 only. [K1]40- `RSPO1041`: set the retention/age in its variant. Also run spool/**TemSe** consistency regularly:41 `RSPO1043` (spool) and the TemSe check (SP12 / SAP Notes 48400, 130978). [K2]4243---4445## 2. Spool & TemSe consistency4647```48SP12 → TemSe consistency check & reorg (temporary sequential objects)49RSPO1043 → spool consistency check50```51Inconsistent TemSe/spool is a common cause of a spool filesystem/table growing despite `RSPO1041`. [K2]5253---5455## 3. OS-level cleanup — the instance work directory5657Work directory: `/usr/sap/<SID>/<INST><nr>/work/` (Windows: `…\work\`). Safe-to-remove candidates when a58filesystem is filling, **oldest first, and never the currently-active file**: [G, K4]5960| Pattern | What it is | Safe to delete? |61|---------|-----------|-----------------|62| `*.OLD` | previous traces, re-created on each restart | ✅ yes |63| `core`, `core.<pid>` | crash core dumps | ✅ after capturing for analysis |64| old `dev_w*`, `dev_rfc*`, `dev_rd` | rotated work-process/RFC/gateway traces | ✅ old ones; not the active |65| `stderr<n>` | per-start stdout/stderr | ✅ old ones |66| `dev_disp`, `dev_ms`, `dev_icm` (current) | live dispatcher/msg/ICM traces | ⚠️ **reset via SM50/SMGW**, don't `rm` while running |6768Reset traces cleanly from the app rather than deleting the active file: **SM50** (work process traces),69**SMGW** (gateway). Also check `/sapmnt/<SID>/global` for old `WF_LOG_*` workflow files.7071## 4. Security audit log ⚠️ retention/compliance7273Audit log files (`*.AUD`) under `/usr/sap/<SID>/<INST><nr>/log/` (SM19/RSAU config, SM20 view). Delete74via **SM18** (or a scheduled reorg), **not** blind `rm`: [G, K3]75```76SM18 → reorganize/delete audit logs older than <retention>77```78> **Confirm the retention requirement with security/audit/compliance before deleting audit logs.** These79> are frequently required to be kept for a mandated period. This is the one cleanup that can create a80> compliance incident.8182## 5. Orphaned IPC / shared memory (`cleanipc`)8384After an instance crash, orphaned shared-memory/semaphore segments can block a restart. Clean them (UNIX):85```bash86cleanipc <nr> remove # remove IPC resources of instance <nr> ⚠️ only when the instance is DOWN87```88Run **only** when that instance is stopped — it wipes the instance's shared memory. [G, K4]8990## 6. Database logs/traces → delegate9192DB transaction/redo/archive logs and DB traces are cleaned with **DB tools**, not `rm`, and only **after a93successful backup**:94- see [sap-db-command-reference](../sap-db-command-reference/SKILL.md) per `dbms_type`;95- e.g. Oracle archived redo via `brarchive -sd` (after backup), Db2 archived logs, HANA log segments +96 backup-catalog housekeeping.97> **Never delete an un-backed-up transaction log** — it breaks point-in-time recovery. [G]9899## 7. "Filesystem full" quick triage100101```bash102df -h # which FS: /usr/sap, /sapmnt, DB data, DB log, /oracle, /hana103du -sh /usr/sap/<SID>/<INST><nr>/work/* | sort -h | tail # biggest offenders in work/104```105Then: §3 (work dir) for `/usr/sap`; §6 (DB, after backup) for the DB/log filesystems; §1 (reorg jobs) so106it doesn't refill. Cross-ref [sap-health-triage](../sap-health-triage/SKILL.md) — full FS is its #1107"won't start / hung" cause.108109## Cross-references110111- **DB-side log cleanup:** [sap-db-command-reference](../sap-db-command-reference/SKILL.md).112- **What's filling it / is it healthy:** [sap-health-triage](../sap-health-triage/SKILL.md).113- **Full standard-jobs list + OS file-type map:** [references/cleanup-catalog.md](references/cleanup-catalog.md).114115## Run as the correct OS user116117**Identify the right OS user *before* running anything, and switch with a login shell.** Wrong-user118execution is a top cause of SAP failures, and the damage outlives the command: files created by `root`119under `/usr/sap`, `/sapmnt` or a DB directory break every later start by the real owner. A login shell120also matters because each user carries the environment the tools need (`SAPSYSTEMNAME`, `ORACLE_HOME`/121`ORACLE_SID`, `SYBASE`, `DB2INSTANCE`, library paths) — without it, commands fail or act on the wrong system.122123| What you're operating | UNIX user | Windows |124|---|---|---|125| SAP instances — `sapcontrol`, `startsap`/`stopsap`, `tp`, `R3trans`, `disp+work`, `sappfpar`, `cleanipc` | **`<sid>adm`** (lower-case **SAP** SID) | `<SID>adm`; services run as `SAPService<SID>` |126| SAP HANA — `HDB`, `hdbsql`, `hdbnsutil` | **`<sid>adm` of the HANA SID** (e.g. `h10adm` — may differ from the SAP SID) | n/a (HANA server is Linux-only) |127| Oracle — `sqlplus`, `lsnrctl`, BR\*Tools | **`ora<dbsid>`** (BR\*Tools also runs as `<sid>adm`; generic installs may use `oracle`) | `<SID>adm`; DB runs as a service |128| SAP ASE — `isql`, `startserver`, Backup Server | **`syb<dbsid>`** | `syb<dbsid>` / `SAPService<SID>` |129| IBM Db2 — `db2start`/`db2stop`, `db2` CLP | **`db2<dbsid>`** (the instance owner = `DB2INSTANCE`) | same; Db2 runs as a service |130| SAP MaxDB / liveCache — `dbmcli`, `x_server` | **`sdb`** (software owner, group `sdba`) + a DBM operator at DB level | install/service account |131| MS SQL Server — `sqlcmd`, service control | n/a (Windows-only for SAP) | `<SID>adm` / the SQL Server service account |132| SAP Host Agent — `saphostexec`, `saphostctrl` | **`root`** | Administrator / `SAPHostExec` service |133134**Rules**135136- **Switch with a login shell:** `su - <user>` (the `-` is what loads the environment) or `sudo -iu <user>`.137 Windows: use the correct account, or an elevated shell only where documented.138- **`root` only where the procedure explicitly says so** — e.g. `saproot.sh` after a kernel extract, SAP Host139 Agent install/upgrade. Never as a shortcut around a permission error; that is how root-owned files get140 created and break the system later.141- **Verify before acting:** `whoami` / `id`, plus the env actually being set (`echo $SAPSYSTEMNAME`,142 `echo $ORACLE_SID`, `echo $DB2INSTANCE`, `echo $SYBASE`).143- **State the user in every command you hand over** (e.g. "as `<sid>adm`:"), and if the required user is not144 available, say so and stop — do not substitute another user.145146## Staying current — check SAP Notes first147148SAP Notes supersede this file. Landscapes differ by release, patch level, DB and OS, and SAP changes149procedures via Notes/KBAs between doc revisions.150151**If the [SAP Notes MCP](https://github.com/marianfoo/sap-mcp-servers) is configured, use it before152acting on anything version-specific** — especially any destructive step, or when a command here doesn't153behave as documented:1541551. `search` the topic (e.g. the component + symptom, or a Note number cited below).1562. `fetch` the promising Note IDs for the current text, validity (affected releases/components),157 prerequisites and side effects.1583. Prefer the Note over this file where they disagree, and say which Note you followed.159160No MCP available? Look the Note up on `me.sap.com/notes/<id>` and say the check was skipped rather than161assuming this file is current.162163## Sources164165- **[K1]** **SAP Note 16083** — *Standard jobs, reorganization jobs* (the canonical list: `RSBTCDEL2`,166 `RSPO1041`, `RSSNAPDL`, `RSBDCREO`, `RSBPSTDE`, `RSM13002`, `RSCOLL00`, …). https://me.sap.com/notes/16083167- **[K2]** `RSPO1041`/`RSPO1043` spool + TemSe consistency — **SAP Notes 130978** (RSPO1041) and **48400**168 (TemSe/spool consistency). https://me.sap.com/notes/48400169- **[K3]** Security audit log housekeeping via **SM18** + retention — SAP Security Audit Log documentation170 (help.sap.com) and SM18/SM19/SM20.171- **[K4]** Work-directory / `*.OLD` / core files / `cleanipc` — SAP OS-file housekeeping (help.sap.com +172 SAP Basis operations).173- **[K5]** *Housekeeping for SAP HANA Platform* (DB-side, for `dbms_type = hdb`).174 https://help.sap.com/doc/f3dd8d9fb4ab407eb15ee4bf336ae42b/9.3/en-US/Housekeeping%20for%20SAP%20HANA.pdf175176**To confirm/deepen** — check current SAP Notes with the SAP Notes MCP (`search`, then `fetch` the note ID): SAP Note 16083 for the full current177job list + report variants, and Note 48400 for the TemSe/spool consistency procedure.