# Run `lsof -i :80` in your devbox shell in quiet mode
devbox run -q lsof -i :80
```

## Run Scripts with Custom Environment Variables[​](#run-scripts-with-custom-environment-variables "Direct link to Run Scripts with Custom Environment Variables")

You can use the `--env` flag to set custom environment variables in your Devbox shell. For example,
the following command will set the `MY_VAR` environment variable to `my_value` when running the
`echo` command:

```bash theme={null}
devbox run --env MY_VAR=my_value echo $MY_VAR
```

You can also load environment variables from a .env file using the `--env-file` flag. For example,
the following command will load the environment variables from the `.env.devbox` file in your
current directory:

```bash theme={null}
devbox run --env-file .env.devbox echo $MY_VAR
```

## Tips on using Scripts[​](#tips-on-using-scripts "Direct link to Tips on using Scripts")

1. Since `init_hook` runs every time you start your shell, you should primarily use it for setting
   environment variables and aliases. For longer running tasks like database setup, you can create
   and run a Devbox script
2. You can use Devbox scripts to start and manage long running background processes and daemons.
   1. For example -- If you are working on a LAMP stack project, you can use scripts to start MySQL
      and Apache in separate shells and monitor their logs. Once you are done developing, you can
      use CTRL-C to exit the processes and shells
3. If a script feels too long to put it directly in `devbox.json`, you can save it as a shell script
   in your project, and then invoke it in your `devbox scripts`.
4. For more ideas, see the LAMP stack example in our
   [Devbox examples repo](https://github.com/jetify-com/devbox/tree/main/examples/stacks/lapp-stack).

[Edit this page](https://github.com/jetify-com/devbox/tree/main/docs/app/docs/guides/scripts.md)