LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 10:02 AM   #1
hack3rcon
Member
 
Registered: Jan 2015
Posts: 909

Rep: Reputation: Disabled
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, 10: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, 09:16 PM   #3
Doug G
Member
 
Registered: Jul 2013
Posts: 595

Rep: Reputation: Disabled
If you can leave the terminal window open, why not just
Code:
netstat -nat <#seconds>
 
Old 12-05-2015, 12:34 PM   #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, 09:47 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,602

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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, 02:54 AM   #6
hack3rcon
Member
 
Registered: Jan 2015
Posts: 909

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

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:52 AM
[SOLVED] how to delete a specific command from terminal history ? dEnDrOn Linux - General 4 08-12-2011 07:29 AM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 11:36 AM
Is there any specific command for clear cache in bash terminal? green_njk Linux - Software 2 11-23-2006 11:22 PM
Running a program for a specific period of time CaptainHowdy Linux - Software 2 08-22-2004 08:02 PM


All times are GMT -5. The time now is 06:51 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration