Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:28:50+00:00 2026-06-15T20:28:50+00:00

I have the following command line that outputs vmstat every second with a time

  • 0

I have the following command line that outputs vmstat every second with a time stamp on each line via the perl script:

vmstat 15 | /home/Beer/addtimestamp.pl > File_1 

the contents of the addtimestamp.pl:

!/usr/bin/perl
while (<>) { print localtime() . ": $_"; }

So why doesn’t the output get redirected to the “File_1” file?

It works perfectly when I don’t, it prints out the output perfectly every second with no issues at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:28:51+00:00Added an answer on June 15, 2026 at 8:28 pm

    When outputting to the terminal, perl’s output is line buffered, so you will see every line as it is output. When its output is a file, it will be block buffered so you will not see any output until a full block is ready to write (4k I think, but variable and system-defined).

    You need to set stdout to use line buffering:

    $|=1;
    

    Search for [perl line buffered output] and you’ll see plenty of results about this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a setup.exe project that I run with the following command-line arguments to
I have the following SQL command that I need to save as a csv
I have the following function that deletes the LaTeX command surrounding the current cursor
I currently have a .command file for Mac that contains the following: for f
I have a very simple command line Java application that I wish to port
I have a file that outputs lines of the following form: $XYZ blah blah
I have a number of command line scripts in PHP that use exec() to
I have an executable that does the following: 1. outputs the string BEGIN 2.
I have two Perl scripts that are supposed to do the following job: Server
I'm having trouble modifying a script that processes files passed as command line arguments,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.