Skip to main content

Ampache CLI Commands

Ampache CLI Commands

Every administrative and maintenance task in Ampache is available from the command line through bin/cli.

This page lists every command grouped by its prefix. For the migration history from the old bin/*.inc scripts see Ampache CLI.

Run the program with no arguments to see the full list, and add -h or --help to any command to see its arguments and options.

php bin/cli
php bin/cli admin:addUser --help

Commands are grouped by a prefix that describes what they touch:

  • admin: — users, access control, licenses, catalog filters, modules, mail and other server administration
  • run: — catalogs and long-running background processes
  • cleanup: — housekeeping of statistics, art and disabled media
  • export: — writing art, playlists and catalog metadata to disk
  • print: — read-only reports printed to the terminal
  • show: — read-only information about the installation

Most admin: and run: commands change your database, so treat them with the same care as the equivalent page in the web interface.

image

admin: — server administration

Many of these commands mirror an action on an Admin page in the web interface and call the same code underneath, so a change made on the command line shows up in the browser and vice versa.

Users

CommandWhat it does
admin:addUserCreate a user account. Takes a <username> argument plus --password, --email, --website, --name and --level options. A random password is generated when none is supplied.
admin:listUsersList every user, or find one by [username] / --user <id>. --apikey prints only the API key.
admin:updateUserUpdate a single user: generate a new --apikey, --streamtoken or --rsstoken, set the --subsonic password, or change the access --level.
admin:deleteUserDelete a user by [username] or --user <id>. Refuses to remove the last active administrator.
admin:enableUserEnable a disabled user.
admin:disableUserDisable a user. Refuses to disable the last active administrator.
# Create a manager-level user with a known password
php bin/cli admin:addUser jane --level 75 --password "s3cr3t" --email jane@example.com

# Rotate a user's API key
php bin/cli admin:updateUser jane --apikey

# Disable, then later delete a user
php bin/cli admin:disableUser jane
php bin/cli admin:deleteUser jane

Access Control Lists

Access Control Lists (ACLs) restrict which addresses may stream, use the API/RPC, reach the web interface, or act as trusted network hosts. These mirror the Admin → Access Control page.

CommandWhat it does
admin:listAclList every ACL with its address range, type, level and assigned user.
admin:addAclAdd an ACL. Takes a <name> argument plus --start, --end, --level, --type (stream, interface, rpc, network), --addtype and --user.
admin:updateAclUpdate an existing ACL by <accessId>.
admin:deleteAclDelete an ACL by <accessId>.
php bin/cli admin:addAcl "office" --start 10.0.0.1 --end 10.0.0.255 --type stream --level 25
php bin/cli admin:listAcl
php bin/cli admin:deleteAcl 7

Licenses

Licenses are the reusable rights labels (Creative Commons, All rights reserved, …) that can be attached to media. These mirror the Admin → Licenses page and are available to managers.

CommandWhat it does
admin:listLicensesList every license by id and name.
admin:addLicenseAdd a license. Takes a <name> argument plus --description, --external_link and --order.
admin:updateLicenseUpdate a license by <licenseId>; omitted options keep their current value.
admin:deleteLicenseDelete a license by <licenseId>.
php bin/cli admin:addLicense "CC BY 4.0" --external_link https://creativecommons.org/licenses/by/4.0/
php bin/cli admin:listLicenses

Catalog filters

Catalog filter groups control which catalogs a group of users can see. These mirror the Admin → Catalog Filters page.

CommandWhat it does
admin:listFiltersList every filter group with its user and catalog counts.
admin:addFilterAdd a filter group. Takes a <name> argument plus --catalogs 1,3 (a comma-separated list of catalog ids to enable) or --all.
admin:updateFilterUpdate a filter group by <filterId>. --catalogs sets the exact enabled set; omit it to keep the current membership.
admin:deleteFilterDelete a filter group by <filterId>. The built-in DEFAULT group (id 0) cannot be deleted.
php bin/cli admin:addFilter "podcasts-only" --catalogs 4
php bin/cli admin:updateFilter 2 --all
php bin/cli admin:listFilters

Modules (plugins, catalog types and localplay)

Ampache has three kinds of pluggable module: application plugins, catalog types (the backends a catalog can use, such as subsonic or beets) and localplay controllers (players such as mpd that Ampache can drive). These mirror the Admin → Modules pages.

CommandWhat it does
admin:listModulesList every plugin, catalog type and localplay controller and whether it is installed.
admin:installPluginInstall (enable) a plugin by <name> and rebuild user preferences so its settings appear.
admin:uninstallPluginUninstall (disable) a plugin by <name>.
admin:upgradePluginUpgrade an installed plugin by <name> to the bundled version.
admin:installCatalogTypeInstall (enable) a catalog type by <type>.
admin:uninstallCatalogTypeUninstall (disable) a catalog type by <type>.
admin:installLocalplayInstall (enable) a localplay controller by <type> and set the localplay preferences for --user.
admin:uninstallLocalplayUninstall (disable) a localplay controller by <type>.
php bin/cli admin:listModules
php bin/cli admin:installPlugin lastfm
php bin/cli admin:installCatalogType subsonic
php bin/cli admin:installLocalplay mpd

See Ampache Plugins for what each plugin does.

image

Shoutbox moderation

Shouts are the short public comments users leave on media. These mirror the Admin → Shoutbox page.

CommandWhat it does
admin:listShoutsList the most recent shouts. --limit sets how many; an optional [username] filters to one user.
admin:deleteShoutDelete a shout by <shoutId>.

Mail

CommandWhat it does
admin:mailUsersSend an e-mail to a group of users. Takes a [group] argument (all, users, admins, inactive) plus --subject and --message. Does nothing when mail is disabled or the server is in demo mode.
php bin/cli admin:mailUsers users --subject "Maintenance" --message "The server restarts at 02:00 UTC."

System administration

CommandWhat it does
admin:updateDatabaseApply any pending database migrations. Run this after upgrading Ampache.
admin:updateConfigFileRegenerate config/ampache.cfg.php, merging in any new options for your installed version.
admin:updatePluginsUpgrade every installed plugin to its bundled version in one pass.
admin:updatePreferenceAccessLevelChange the access level required to edit a preference.
admin:resetPreferencesReset preference values back to their defaults for users.
admin:clearCacheClear a cache by [type]. Only perpetual_api_session has a lasting effect (it removes stored perpetual API sessions); the song, artist and album object caches live only for a single process.
admin:exportSchemaRegenerate the resources/sql/ampache.sql seed dump from the current database. A development/release tool; it refuses to run when migrations are pending.

run: — catalogs and background processes

Catalogs

CommandWhat it does
run:addCatalogCreate a local media catalog. Takes [catalogName], [catalogPath], [mediaType] (music, video, podcast), [filePattern] and [folderPattern].
run:updateCatalogPerform catalog actions across all files: clean, add, gather art, verify and garbage-collect. With no options the defaults -ceagt are used. Accepts a [catalogName] and [catalogType].
run:updateCatalogFilePerform catalog actions for a single file.
run:updateCatalogFolderPerform catalog actions for a single folder.
run:deleteCatalogDelete a catalog by <catalogId> and everything it owns.
run:enableCatalogEnable a catalog by <catalogId>.
run:disableCatalogDisable a catalog by <catalogId> without deleting it.
run:moveCatalogPathUpdate the stored file locations for a catalog after a mount point has changed.
php bin/cli run:addCatalog music /media/music music
php bin/cli run:updateCatalog music
php bin/cli run:disableCatalog 3

The -v verify switch from Ampache 4 is now -e; see Command changes.

Background processes

CommandWhat it does
run:cronProcessRun the scheduled cron tasks. Intended to be triggered from the system cron. See CRON.
run:cacheProcessPopulate the transcode cache.
run:computeCacheRebuild the object cache tables.
run:calculateArtSizeFill in the stored width/height for art.
run:convertFilenamesConvert file names in the database to a different character set.
run:broadcastRun a UPnP broadcast.
run:websocketRun the WebSocket server used by the now-playing broadcast feature.
run:updateDbUpdate the database collation and character set.

cleanup: — housekeeping

CommandWhat it does
cleanup:statsClear play statistics and/or the now-playing list. With no flag both are cleared; --stats, --now-playing and --user narrow it.
cleanup:enableDisabledRe-enable every song that was previously disabled.
cleanup:songsDelete songs that are currently disabled.
cleanup:artRemove art that no longer fits the configured size/keep settings.
cleanup:sortSongsMove song files into place according to the catalog sort pattern.
cleanup:consolidateStatsConsolidate old play history into summary counts and archive the detail rows.
cleanup:restoreStatsRestore consolidated play history back from the archive.
# Clear only the now-playing list, leaving history intact
php bin/cli cleanup:stats --now-playing

export: — writing files to disk

CommandWhat it does
export:catalogExport catalog metadata to a file. Takes a <file> argument and a [format] (csv or itunes); --catalog limits it to one catalog.
export:playlistExport playlists to a directory as m3u, pls, xspf or m3u8.
export:albumArtExport embedded/side-car album art to the catalog folders.
export:databaseArtExport all art stored in the database to the local_metadata_dir.
php bin/cli export:catalog /backup/library.csv csv
CommandWhat it does
print:duplicatesPrint possible duplicate albums, artists or songs. [type] selects what to look for.
print:tagsPrint the tags Ampache reads from a media file.

show: — installation information

CommandWhat it does
show:debugPrint a headless status and environment report: version, structure, PHP version, last cron run and a pass/fail list of the runtime prerequisites. Add --check-updates to also query the remote latest version.
show:versionPrint the Ampache version.
php bin/cli show:debug

image