Linux Save the output of a command in a logfile
You can use logsave command to save the output of a command in a logfile. General syntax is as follows:
logsave /path/to/logfile command-name argument(s)
The logsave program will execute command-name 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 command-name 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. For example, save output of ls command to output.log file:
logsave /tmp/output.txt ls
For example run lftp and save remote server file list to /tmp/filelist.txt for other scripts:
logsave /tmp/filelist.txt 'lftp -u -e "cd pub;ls;quit;" admin,mypassword ftp.nixcraft.in '
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or full RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in...
- Linux / UNIX: display time of different time zones using TZ environment variable
- Executing script or command on the last day of a month
- How to rewind tapes fast and save typing time
- Quick Tip: Run wget in background for an unattended download of files
- How to keep files safe from accidental overwriting with noclobber under BASH shell
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: boot scripts, Linux, save command output to file, UNIX ~ Last updated on: November 11, 2007



Recent Comments
Today ~ 2 Comments
Today ~ 37 Comments
Today ~ 1 Comment
Yesterday ~ 12 Comments
Yesterday ~ 2 Comments