run_erl(1)
π run_erl π
okay bestie, welcome to the Erlang Module Definition manual, and today's main character is run_erl β a lil Unix-only program that does unbelievably important work and gets zero credit. this is run_erl(1), and no, you can't use it on Windows, it said Unix systems, plural, and it meant it. π¦
β¨ NAME β¨
run_erl β redirect Erlang input and output streams on Unix systems π
πΈ DESCRIPTION πΈ
okay so run_erl is specific to Unix systems, like that's its whole personality. what it does is redirect the standard input and standard output streams so that all output can be logged. and that's not even the best part β it also lets the program to_erl connect to the Erlang console, which means you can monitor and debug an embedded system remotely. yes. from afar. iconic. π
for more info about how to actually use it, go read the Embedded System User's Guide in System Documentation. iykyk.
run_erl [-daemon] pipe_dir/ log_dir "exec command arg1 arg2 ..."
here come the arguments, pay attention bestie, there's a β¨trickβ¨ in one of them:
-daemonβ okay this one is highly recommended, fr fr. it makesrun_erlrun in the background, completely detached from any controlling terminal, and the command returns to whoever called it immediately. if you don't use it, you have to startrun_erlusing several tricks in the shell to detach it completely from the terminal in use when starting it. several. tricks. in the shell. no thank you. π« this option must be the first argument torun_erlon the command line β first. not second. first. πpipe_dirβ this is the named pipe, usually/tmp/.and here's the thing bestie, it must be suffixed by a/(slash). like,/tmp/epipes/, not/tmp/epipes. the slash is load-bearing. do not take the slash away from her. πlog_dirβ the log files live here, and there's a whole lil family of them:- one log file,
run_erl.log, which logs progress and warnings from therun_erlprogram itself. that's her diary. π - up to five log files at maximum 100 KB each, with the content of the standard streams from and to the command. (both the number of logs and the sizes can be changed by environment variables, see the Environment Variables section below β we'll get there, don't worry π)
- when the logs are full,
run_erldeletes and reuses the oldest log file. recycling queen. β»οΈ
- one log file,
"exec command arg1 arg2 ..."β a space-separated string specifying the program to be executed. the second field is typically a command name such aserl. slay. β¨
π Notes concerning the Log Files π
while it's running, run_erl sends all output, uninterpreted, to a log file. no editing, no vibes-checking it, just raw. the file is named erlang.log.N, where N is an integer. when the log is "full" (default log size is 100 KB), run_erl starts to log in file erlang.log.(N+1), until N reaches a certain number (default 5), whereupon N starts at 1 again and the oldest files start getting overwritten. it's a little carousel of logs bestie, round and round. π
now, if no output comes from the Erlang shell, but the Erlang machine still seems to be alive, an "ALIVE" message is written to the log. it's a time stamp, and it's written, by default, after 15 minutes of inactivity. just a little "hey, still here π«Ά".
also, if output from Erlang is logged, but more than 5 minutes (default) has passed since we last got anything from Erlang, a time stamp is written in the log.
the "ALIVE" messages look as follows:
===== ALIVE <date-time-string>
and the other time stamps look as follows:
===== <date-time-string>
date-time-string is the date and time the message is written, default in local time (can be changed to UTC if needed, more on that in a sec). it's formatted with the ANSI-C function strftime using the format string %a %b %e %T %Z %Y, which produces messages like ===== ALIVE Thu May 15 10:13:36 MEST 2003. and yes, that can be changed too β see the next section. π
π Environment Variables π
the following environment variables are recognized by run_erl and change the logging behavior. for more information, see the previous section (you literally just read it, bestie, you're so prepared β¨).
RUN_ERL_LOG_ALIVE_MINUTESβ how long to wait for output (in minutes) before writing an"ALIVE"message to the log. defaults to 15, minimum is 1.RUN_ERL_LOG_ACTIVITY_MINUTESβ how long Erlang needs to be inactive before output is preceded with a time stamp. defaults toRUN_ERL_LOG_ALIVE_MINUTES div 3, minimum is 1.RUN_ERL_LOG_ALIVE_FORMATβ specifies another format string to be used in thestrftimeC library call. that is, specifying this to"%e-%b-%Y, %T %Z"gives log messages with time stamps like15-May-2003, 10:23:04 MET. for more information, see the documentation for the C library functionstrftime. defaults to"%a %b %e %T %Z %Y".RUN_ERL_LOG_ALIVE_IN_UTCβ if set to anything else than0, it makes all times displayed byrun_erlto be in UTC (GMT, CET, MET, without Daylight Saving Time), rather than in local time. this does not affect data coming from Erlang, only the logs output directly byrun_erl. Application SASL can be modified accordingly by setting the Erlang application variableutc_logtotrue. timezone glow-up. πRUN_ERL_LOG_GENERATIONSβ controls the number of log files written before older files are reused. defaults to 5, minimum is 2, maximum is 1000.
note that, as a way to indicate the newest file,run_erlwill delete the oldest log file to maintain a "hole" in the file sequences. for example, if log files#1,#2,#4and#5exist, that means#2is the latest and#4is the oldest. you will therefore get at most one less log file than the value set byRUN_ERL_LOG_GENERATIONS. the missing file IS the signal. it's giving detective work. π
RUN_ERL_LOG_MAXSIZEβ the size, in bytes, of a log file before switching to a new log file. defaults to 100000, minimum is 1000, maximum is about 2^30.RUN_ERL_DISABLE_FLOWCNTRLβ if defined, disables input and output flow control for the pty opened byrun_erl. useful if you want to remove any risk of accidentally blocking the flow control by using Ctrl+S (instead of Ctrl+D to detach), which can result in blocking of the entire Beam process, and in the case of runningheartas supervisor even theheartprocess becomes blocked when writing log message to terminal, leaving theheartprocess unable to do its work. π so yeah. Ctrl+S is not your friend here. Ctrl+D is. π«Ά
π¦ See Also π¦
start(1), start_erl(1) β go read your siblings, bestie, they miss you π
and that's the whole page!! π brought to you by Ericsson AB, running erts 17.0.6, and this is run_erl(1) signing off. stay logged, stay detached from your controlling terminal, and remember: put the slash in pipe_dir. periodt. π
β¨π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms