≡ Menu

logsave – save output of a Linux command to a file

The command logsave can be used to save the output of a command to a log file. This is very useful for the initial boot scripts as while booting, the /var file system is not yet mounted.

From the man page:

The logsave program will execute cmd_prog with the specified argument(s), and save a copy of its output to logfile. If the containing directory for logfile does not exist, logsave will accumulate the output in memory until it can be written out. A copy of the output will also be written to standard output.
If cmd_prog is a single hyphen (‘-’), then instead of executing a program, logsave will take its input from standard input and save it in logfile

logsave is useful for saving the output of initial boot scripts until the /var partition is mounted, so the output can be written to /var/log.

The syntax of the command is as follows:

logsave file.txt {command}

For example:

[root@server ~]# logsave file.txt find . | head -n 10
[root@server ~]#

The above command will save the output of the find command to a file called file.txt.

Comments on this entry are closed.