Linux command
erl 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start Erlang shell
erl
Run with module
erl -s [module] [function]
Run and halt
erl -noshell -s [module] [function] -s init stop
Start named node
erl -name [node@host]
Set cookie for
erl -setcookie [secret]
Load paths
erl -pa [ebin/]
Evaluate expression
erl -eval "[io:format(\"Hello~n\")]"
说明
erl starts the Erlang runtime system and interactive shell. It's the primary way to run Erlang programs, either interactively or in batch mode. The shell provides an interactive environment for evaluating Erlang expressions. For production use, -noshell runs without the shell, and -s/-eval execute specific code. Erlang's distributed features are enabled through node naming (-name/-sname) and authentication (-setcookie).
参数
- -s _MOD_ _FUNC_ [_ARGS_]
- Start module function.
- -noshell
- Run without interactive shell.
- -name _NAME_
- Long node name.
- -sname _NAME_
- Short node name.
- -setcookie _COOKIE_
- Distribution cookie.
- -pa _DIR_
- Prepend to code path.
- -eval _EXPR_
- Evaluate expression at startup.
- -run _MOD_ _FUNC_ [_ARGS_]
- Similar to -s but passes arguments as a list of strings.
- -config _FILE_
- Application configuration file (sys.config).
- -detached
- Start the Erlang runtime system detached from the controlling terminal.
- -heart
- Start a heartbeat monitoring process.
- +P _NUM_
- Set maximum number of concurrent processes (default 262144).
- +K _true|false_
- Enable or disable kernel poll (epoll/kqueue).
FAQ
What is the erl command used for?
erl starts the Erlang runtime system and interactive shell. It's the primary way to run Erlang programs, either interactively or in batch mode. The shell provides an interactive environment for evaluating Erlang expressions. For production use, -noshell runs without the shell, and -s/-eval execute specific code. Erlang's distributed features are enabled through node naming (-name/-sname) and authentication (-setcookie).
How do I run a basic erl example?
Run `erl` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s _MOD_ _FUNC_ [_ARGS_] do in erl?
Start module function.