Use long options in command line examples
[lttng-docs.git] / contents / using-lttng / controlling-tracing / creating-destroying-tracing-sessions.md
CommitLineData
5e0cbfb0
PP
1---
2id: creating-destroying-tracing-sessions
3---
4
5Whatever you want to do with `lttng`, it has to happen inside a
6**tracing session**, created beforehand. A session, in general, is a
7per-user container of state. A tracing session is no different; it
8keeps a specific state of stuff like:
9
10 * session name
11 * enabled/disabled channels with associated parameters
12 * enabled/disabled events with associated log levels and filters
13 * context information added to channels
14 * tracing activity (started or stopped)
15
16and more.
17
18A single user may have many active tracing sessions. LTTng session
19daemons are the ultimate owners and managers of tracing sessions. For
20user space tracing, each user has its own session daemon. Since Linux
21kernel tracing requires root privileges, only `root`'s session daemon
22may enable and trace kernel events. However, `lttng` has a `--group`
23option (which is passed to `lttng-sessiond` when starting it) to
24specify the name of a _tracing group_ which selected users may be part
25of to be allowed to communicate with `root`'s session daemon. By
26default, the tracing group name is `tracing`.
27
28To create a tracing session, do:
29
30<pre class="term">
31lttng create my-session
32</pre>
33
34This will create a new tracing session named `my-session` and make it
35the current one. If you don't specify any name (calling only
36`lttng create`), your tracing session will be named `auto`. Traces
37are written in <code>~/lttng-traces/<em>session</em>-</code> followed
38by the tracing session's creation date/time by default, where
39<code><em>session</em></code> is the tracing session name. To save them
40at a different location, use the `--output` option:
41
42<pre class="term">
43lttng create --output /tmp/some-directory my-session
44</pre>
45
46You may create as many tracing sessions as you wish:
47
48<pre class="term">
49lttng create other-session
50lttng create yet-another-session
51</pre>
52
53You may view all existing tracing sessions using the `list` command:
54
55<pre class="term">
56lttng list
57</pre>
58
59The state of a _current tracing session_ is kept in `~/.lttngrc`. Each
60invocation of `lttng` reads this file to set its current tracing
61session name so that you don't have to specify a session name for each
62command. You could edit this file manually, but the preferred way to
63set the current tracing session is to use the `set-session` command:
64
65<pre class="term">
66lttng set-session other-session
67</pre>
68
69Most `lttng` commands accept a `--session` option to specify the name
70of the target tracing session.
71
72Any existing tracing session may be destroyed using the `destroy`
73command:
74
75<pre class="term">
76lttng destroy my-session
77</pre>
78
79Providing no argument to `lttng destroy` will destroy the current
80tracing session. Destroying a tracing session will stop any tracing
81running within the latter. Destroying a tracing session frees resources
82acquired by the session daemon and tracer side, making sure to flush
83all trace data.
84
85You can't do much with LTTng using only the `create`, `set-session`
86and `destroy` commands of `lttng`, but it is essential to know them in
87order to control LTTng tracing, which always happen within the scope of
88a tracing session.
This page took 0.025205 seconds and 4 git commands to generate.