RUN-PARTS(8)
๐ NAME ๐
run-parts โ runs the scripts or programs chillin' in a directory, no cap ๐ธ
๐ฆ SYNOPSIS ๐ฆ
run-parts [--test] [--verbose] [--debug] [--report] [--lsbsysinit]
[--regex=RE] [--umask=umask] [--arg=argument] [--after=PROG]
[--before=PROG] [--exit-on-error] [--help] [--version] [--list]
[--reverse] [--] DIRECTORY [DIRECTORY ...]
run-parts -V
โจ DESCRIPTION โจ
okay so basically, run-parts goes through directory and runs all the executable files that match the rules we're about to spill below. Any other file? Any directory? silently ignored. Not a word. Not a peep. It's giving "not my business" energy ๐
So here's the vibe check on which filenames get to be picked, depending on which flag you use:
- If you give it neither
--lsbsysinitnor--regex, then the names have to be made up entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens. That's it. That's the whole guest list. - If you pass
--lsbsysinit, then the names must not end in.dpkg-oldor.dpkg-distor.dpkg-newor.dpkg-tmp, and they have to belong to one or more of these namespaces:- the LANANA-assigned namespace (
^[a-z0-9]+$) - the LSB hierarchical and reserved namespaces (
^_?([a-z0-9_.]+-)+[a-z0-9]+$) - the Debian cron script namespace (
^[a-zA-Z0-9_-]+$)
- the LANANA-assigned namespace (
- If you pass
--regex, then the names just have to match whatever custom extended regular expression you fed it as that option's argument. Your regex, your rules, main character behavior fr fr.
The files get run sequentially, in the lexical sort order of their names (that's per the C/POSIX locale character collation rules, iykyk) โ unless you pass --reverse, in which case bestie runs them in the opposite order. Iconic.
And now the plot twist: if you hand it more than one DIRECTORY, then files with the same name in the earlier directories take precedence over files in directories you listed later. Why does that matter? Because it lets run-parts take directories with scripts in both /usr and /etc, and let the files in /etc override the scripts in /usr when they're named the same ๐ซถ For that to actually happen, the directory under /etc needs to be specified before the path under /usr. Order matters, bestie. Periodt.
๐ OPTIONS ๐
--testโ prints the names of the scripts that would run, but doesn't actually run them. Window shopping only, no purchasing ๐๏ธ--listโ prints the names of all matching files (not just the executables), but doesn't actually run them. > heads up: this option cannot be used with--test. Pick a lane.-v,--verboseโ prints the name of each script to stderr before running it.--reportโ kinda like--verbose, except it only prints the name of scripts which actually produce output. And it prints the script's name to whichever of stdout or stderr the script first produces output on. Sleek, honestly.-d,--debugโ prints to stderr which scripts got selected for running and which ones didn't. Full transparency, we love to see it ๐ฅ--reverseโ reverses the scripts' execution order. Backwards babe ๐--exit-on-errorโ bails out the second a script returns with a non-zero exit code. No patience, and honestly? Valid.--stdinโ multiplexes stdin to the scripts being run, using a temporary file.--lsbsysinitโ uses the LSB namespaces instead of the classical behavior.--new-sessionโ runs each script in its own separate process session. > โ ๏ธ careful babes: if you use this option, killingrun-partswill not kill the currently running script โ it'll just run until it finishes. It does not care. It will not be stopped.--regex=REโ validates filenames against the custom extended regular expression RE. There's an example down in the EXAMPLES section, go peek ๐-u,--umask=umaskโ sets the umask to umask before running the scripts. umask should be given in octal. By default the umask is set to022.-a,--arg=argumentโ passes argument to the scripts. Use--argonce for each argument you want passed. Stack 'em up ๐-A,--after=programโ runs program after each script runs. The program gets called with three arguments: the script name, the exit status, and the total amount written to the output and error streams. That last argument will always be0unless the--reportoption is also specified. If you use this option multiple times, only the last one takes effect. And if the called program exits with an error code, it won't be called again. One strike, you're out โ-B,--before=programโ runs program before running each script. The program gets called with one argument: the script name. If you use this option multiple times, only the last one takes effect. Same deal as above: if the called program exits with an error code, it won't be called again.--โ declares that this is the end of the options. Any filename after--will not be interpreted as an option, even if it starts with a hyphen. Protection mode: activated ๐ก๏ธ-h,--helpโ displays usage information and exits.-V,--versionโ displays version and copyright and exits.
๐ EXAMPLES ๐
Wanna print the names of all files in /etc that start with p and end with d? Say less:
run-parts --list --regex '^p.*d$' /etc
๐ COPYRIGHT ๐
- Copyright (C) 1994 Ian Jackson.
- Copyright (C) 1996 Jeff Noxon.
- Copyright (C) 1996, 1997, 1998 Guy Maor
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Clint Adams
run-parts is free software; see the GNU General Public License version 2 or later for copying conditions. There is no warranty.
and that's the whole page bestie ๐ this lil' slice of the System Manager's Manual (RUN-PARTS(8)) came from Debian, dated 27 Jun 2012 โ go run some scripts responsibly, mwah ๐
โจ
๐ฆ where this page comes from
- arch rolling: run-parts 5.24-1 ยท GPL-2.0-or-later
- ubuntu stonking: debianutils 5.24 ยท GPL-2.0-or-later
- Copyright 1994 by Ian Jackson
- Copyright 1996 by Jeff Noxon
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms