LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2015, 09:02 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post Running a command and see the output in terminal in specific time.


Hello.
I want to run a command like "netstat -nat" every 1 minute and see the output in terminal. Should I use cron? Or I have another options too?

Thank you.
 
Old 12-04-2015, 09:23 AM   #2
LanceTaylor
Member
 
Registered: Nov 2015
Location: Houston, Texas, US
Distribution: RHEL/CentOS, Debian/Linux Mint, SLES
Posts: 40

Rep: Reputation: 19
Quote:
Originally Posted by hack3rcon View Post
I want to run a command like "netstat -nat" every 1 minute and see the output in terminal.
The watch command is designed to do that. Just give it the number of seconds as an argument:
Code:
watch -n 60 netstat -nat
 
1 members found this post helpful.
Old 12-04-2015, 08:16 PM   #3
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
If you can leave the terminal window open, why not just
Code:
netstat -nat <#seconds>
 
Old 12-05-2015, 11:34 AM   #4
LanceTaylor
Member
 
Registered: Nov 2015
Location: Houston, Texas, US
Distribution: RHEL/CentOS, Debian/Linux Mint, SLES
Posts: 40

Rep: Reputation: 19
Quote:
Originally Posted by Doug G View Post
If you can leave the terminal window open, why not just
Code:
netstat -nat <#seconds>
That option is not available in every version of netstat.
 
Old 12-05-2015, 08:47 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Netstat itself has a delay option between iterations. One advantage this has is that cumulative information can be displayed, rather than just since the last command.
 
Old 12-06-2015, 01:54 AM   #6
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Can I use "watch" with more than one command?
 
Old 12-06-2015, 05:02 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by hack3rcon View Post
Can I use "watch" with more than one command?
Of course.

It may only watch one command...
but that command can be bash which can combine multiple commands...
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Running batch file does not produce same results as running command from Terminal nmuleski Linux - Newbie 9 12-30-2011 09:52 AM
[SOLVED] how to delete a specific command from terminal history ? dEnDrOn Linux - General 4 08-12-2011 06:29 AM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 10:36 AM
Is there any specific command for clear cache in bash terminal? green_njk Linux - Software 2 11-23-2006 10:22 PM
Running a program for a specific period of time CaptainHowdy Linux - Software 2 08-22-2004 07:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration