Command output is not saved

Command output is not saved, why?

my_snap_app >> log.txt

$ ls -l
-rw-rw-r-- 1 user user    0 дек 18 11:53 log.txt

As input/output redirection is actually handled by the shell instead of snapd it’s pretty much a shell problem.

Refer the Basic Shell Features > Redirection section of the Bash manual:

   Each redirection that may be preceded by a file descriptor number

   ... redacted ...

   In the following descriptions, if the file descriptor number is
omitted, and the first character of the redirection operator is '<', the
redirection refers to the standard input (file descriptor 0).  If the
first character of the redirection operator is '>', the redirection
refers to the standard output (file descriptor 1).
3.6.3 Appending Redirected Output
Redirection of output in this fashion causes the file whose name results
from the expansion of WORD to be opened for appending on file descriptor
N, or the standard output (file descriptor 1) if N is not specified.  If
the file does not exist it is created.
   The general format for appending output is:
     [N]>>WORD

Is my_snap_app really printing output to the standard output device? If it’s printing to the standard error device you should use the file descriptor 2 instead:

my_snap_app 2>> log.txt
1 Like

Thanks for the help!

1 Like