We log search terms to improve our documentation. For more information, read our Privacy Policy.
The webapp_cleanup Script
Valid for versions 138 through the latest version
Version:
138
Last modified: 2026 October 13
Overview
The /usr/local/cpanel/scripts/webapp_cleanup.pl script lists the leftover files and directories that a web app leaves in a cPanel account’s home directory. These include staging directories that no web app uses and leftovers from an interrupted attempt to add or replace a web app’s source. They also include per-deploy and per-build logs. To remove these leftovers, run the script with the --run option.
Users deploy and manage web apps in the Websites hub of cPanel’s Meridian theme. For more information, read our Manage a Node.js App documentation.
- You must run this script as the
rootuser. - This script does not run automatically.
- If the script cannot run for a cPanel account, it reports the problem and continues with the remaining accounts.
Run the script
To run this script on the command line, use the following format:
/usr/local/cpanel/scripts/webapp_cleanup.pl [options]Options
Use the following options with this script:
| Option | Description | Example |
|---|---|---|
--run |
Remove the leftovers. Without this option, the script only lists what it would remove and does not change anything. | /usr/local/cpanel/scripts/webapp_cleanup.pl --run |
--days=N |
Consider leftovers older than N days. The default is 30. Use --days=0 to consider all of them. |
/usr/local/cpanel/scripts/webapp_cleanup.pl --days=7 |
--user=NAME |
Clean a single account instead of all accounts on the server. | /usr/local/cpanel/scripts/webapp_cleanup.pl --user=username |
--help, -h |
Display the script’s help text. | /usr/local/cpanel/scripts/webapp_cleanup.pl --help |
What the script removes
In the following table, <name> is the web app’s name, <unixtime> is a Unix epoch timestamp, and <deploy_id> is the ID of the deployment. The script looks for the following leftovers in each account’s home directory:
| Leftover | Location |
|---|---|
| Staging directory that does not belong to any web app in the account. | ~/.cpanel/webapp-staging/<name>/ |
| Leftover directories from an interrupted attempt to add or replace a web app’s source. | ~/.cpanel/webapp-staging/<name>/source.incoming and ~/.cpanel/webapp-staging/<name>/source.rollback |
| Per-deploy log. | ~/.cpanel/logs/<unixtime>-deploy-<name>.log |
| Per-build log. | ~/.cpanel/webapp-logs/<name>/build-<deploy_id>.log |
- When the script removes a staging directory, it also removes that web app’s log directory,
~/.cpanel/webapp-logs/<name>/, and everything in it. The list of leftovers does not show this log directory. - The script measures age from the time that a leftover last changed.
What the script keeps
The script does not remove the following:
- The most recent deployment’s logs for each web app, including deleted web apps. This lets you inspect the last result.
- Leftovers that belong to a web app with a deployment in progress.
- The staging directory of a web app that still exists in the account, even if it is older than the
--daysvalue. - Leftovers in an account while its web app registry is in use. For example, the registry is in use when a user is staging a web app or changing a web app’s settings.
- The
app.logfile of each web app that still exists in the account.
Exit codes
The script returns one of the following exit codes:
0— The script finished without a failure. The script can keep an item and still return0. The following reasons do not count as failures:registry_busy— The account’s web app registry was in use.deploy_in_progress— The web app has a deployment in progress.
1— The script could not read or remove leftover data. The script returns1for the following reasons:remove_failed— The script could not remove the leftover.unreadable— The script could not read a directory or file.symlinked_root— The~/.cpanel/webapp-staging,~/.cpanel/webapp-logs, or~/.cpanel/logsdirectory is a symbolic link. The script does not follow symbolic links.registry_unreadable— The script could not read the account’s web app registry.UNKNOWN— The script could not clean the account and writes the cause to the standard error output.
2— You passed an invalid option or value, or you did not run the script as therootuser.
Examples
The following example runs the script without the --run option to list the leftovers it marks for removal.
/usr/local/cpanel/scripts/webapp_cleanup.plIn the output, the script calls each leftover an artifact. The text in parentheses shows the kind of leftover (orphaned_staging, intake_leftover, deploy_log, or build_log) and its age:
|
|
With the --run option, the script prints Removing. instead of the Listing only line, and each line that lists a leftover ends with — REMOVED.
To list the leftovers that are older than seven days in a single account:
/usr/local/cpanel/scripts/webapp_cleanup.pl --user=username --days=7To remove the leftovers that are older than 30 days from all accounts:
/usr/local/cpanel/scripts/webapp_cleanup.pl --run