• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Saving every command and its output in log in Unix

November 25, 2011 by Sharad Chhetri Leave a Comment

In this post we will learn about saving every linux/unix command and its output in log file. The command called script will be use to save the command output in log.

Run script command to save command output in file/log

script  filename.log

Example:

[root@server1 ~]#
[root@server1 ~]# script my.log
Script started, file is my.log
Welcome
[root@server1 ~]#
[root@server1 ~]# date
Thu Nov 24 23:02:39 MST 2011
[root@server1 ~]#
[root@server1 ~]# cal
   November 2011
Su Mo Tu We Th Fr Sa
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

[root@server1 ~]#
[root@server1 ~]# echo "This is  a test"
This is  a test
[root@server1 ~]#
[root@server1 ~]# exit
exit
Script done, file is my.log
[root@server1 ~]#

Now we will see output in my.log file.

[root@server1 ~]#
[root@server1 ~]#  cat my.log
Script started on Thu Nov 24 23:02:35 2011
Welcome
[root@server1 ~]#
[root@server1 ~]# date
Thu Nov 24 23:02:39 MST 2011
[root@server1 ~]#
[root@server1 ~]# cal
   November 2011
Su Mo Tu We Th Fr Sa
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

[root@server1 ~]#
[root@server1 ~]# echo "This is  a test"
This is  a test
[root@server1 ~]#
[root@server1 ~]# exit
exit

Script done on Thu Nov 24 23:03:05 2011
[root@server1 ~]#

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Secondary Logging : Save All Users History Command Output As Log
  2. See mysql command output vertically
  3. Print grep command output without seperator
  4. Learn tar command and know about its precaution
  5. Set group password,its use and check which group after newgrp command in linux
  6. Linux : clear command and its keyboard shortcut
  7. check_memory unable to read output Nagios nrpe
  8. Redirect sudo output to file
  9. How To Find Absolute Full Path Of Command On Linux / Unix : which command
  10. How to create OpenSSH rpm package and its upgrade

Filed Under: Linux Tagged With: logging

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

How to know last command run successfully : Linux / Unix

Learn Linux Date Command With Examples

How to free pagecache, dentries and inodes from memory on linux

learn very useful alias command with examples

vi : Edit file without opening it

group ownership reference to file/dir from other file/dir in linux

Linux : clear command and its keyboard shortcut

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Error installing rails

How to find swap partition or file in linux

How to find when Operating system was installed in linux CentOS and Red Hat

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Protect from w00tw00t.at.blackhats.romanian.anti-sec

New XAMPP security concept

Replace keyword with its filename without extension : bash script

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ·
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy