# man > envdir(8)

---
type: CommandReference
command: envdir
mode: man
section: 8
source: man-pages
---

## Quick Reference

- `envdir /etc/envdir /usr/bin/daemon` — Run daemon with environment variables from /etc/envdir
- `echo "myvalue" > /etc/envdir/MYVAR` — Set environment variable `MYVAR` to `myvalue` for the child process
- `touch /etc/envdir/CLEAR_VAR` — Remove environment variable `CLEAR_VAR` (empty file deletes it)

## Name

**envdir** — runs another program with environment modified according to files in a specified directory.

## Synopsis

`envdir d child`

## Description

`d` is a single argument. `child` consists of one or more arguments.

`envdir` sets various environment variables as specified by files in the directory named `d`. It then runs `child`.

If `d` contains a file named `s` whose first line is `t`, `envdir` removes an environment variable named `s` if one exists, and then adds an environment variable named `s` with value `t`. The name `s` must not contain `=`. Spaces and tabs at the end of `t` are removed. Nulls in `t` are changed to newlines in the environment variable.

If the file `s` is completely empty (0 bytes long), `envdir` removes an environment variable named `s` if one exists, without adding a new variable.

## Examples

shell
# Create a directory with environment files
mkdir -p /etc/myenvdir
echo "localhost" > /etc/myenvdir/DATABASE_HOST
echo "5432" > /etc/myenvdir/DATABASE_PORT

# Run a program with those environment variables
envdir /etc/myenvdir /opt/app/myapp
## Exit Codes

`envdir` exits 111 if it has trouble reading `d`, if it runs out of memory for environment variables, or if it cannot run `child`. Otherwise its exit code is the same as that of `child`.

## See Also

- [supervise(8)](https://man7.org/linux/man-pages/man8/supervise.8.html)
- [svc(8)](https://man7.org/linux/man-pages/man8/svc.8.html)
- [svok(8)](https://man7.org/linux/man-pages/man8/svok.8.html)
- [svstat(8)](https://man7.org/linux/man-pages/man8/svstat.8.html)
- [svscanboot(8)](https://man7.org/linux/man-pages/man8/svscanboot.8.html)
- [svscan(8)](https://man7.org/linux/man-pages/man8/svscan.8.html)
- [readproctitle(8)](https://man7.org/linux/man-pages/man8/readproctitle.8.html)
- [fghack(8)](https://man7.org/linux/man-pages/man8/fghack.8.html)
- [pgrphack(8)](https://man7.org/linux/man-pages/man8/pgrphack.8.html)
- [multilog(8)](https://man7.org/linux/man-pages/man8/multilog.8.html)
- [tai64n(8)](https://man7.org/linux/man-pages/man8/tai64n.8.html)
- [tai64nlocal(8)](https://man7.org/linux/man-pages/man8/tai64nlocal.8.html)
- [setuidgid(8)](https://man7.org/linux/man-pages/man8/setuidgid.8.html)
- [envuidgid(8)](https://man7.org/linux/man-pages/man8/envuidgid.8.html)
- [softlimit(8)](https://man7.org/linux/man-pages/man8/softlimit.8.html)
- [setlock(8)](https://man7.org/linux/man-pages/man8/setlock.8.html)
- [daemontools](http://cr.yp.to/daemontools.html)