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 08-04-2010, 01:11 PM   #1
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Rep: Reputation: 0
Problem with watch function


Hello,
I've never used Linux, but I have to use it for the thesis.
I want to monitorate the performances of a multiprocessor node, the IT department told me to use:
"watch --interval=1800 "pdsh -w comp[12,34,45] uptime""

but I want to save the information on a file, is it possible?
I was even looking this http://linux.die.net/man/8/md-mx-ctrl.
I am interested in the load of the nodes, since there are three nodes working.

Thank you very much for the interest

Regards

Antonio
 
Old 08-04-2010, 02:09 PM   #2
wagaboy
Member
 
Registered: Jun 2010
Distribution: Ubuntu 10.04, Cent OS 5.5, CLE3
Posts: 51

Rep: Reputation: 21
Displays the output on the screen and logs the output to a file.
Code:
watch --interval=1800 "pdsh -w comp[12,34,45] uptime | tee -a logfile"
 
Old 08-04-2010, 03:10 PM   #3
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you very much!
 
Old 08-04-2010, 04:40 PM   #4
hanishmadan
LQ Newbie
 
Registered: Jan 2010
Posts: 8

Rep: Reputation: 0
you can do it like below also: -

watch --interval=1800 "pdsh -w comp[12,34,45] uptime >> log.txt.
 
Old 08-04-2010, 04:59 PM   #5
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you!

Just for understanding, the commands should write the output in the file as appending, isn't it?

Because I tried the
Quote:
watch --interval=1800 "pdsh -w comp[12,34,45] uptime | tee -a logfile"
but was not updating the file...

Cheers

Antonio
 
Old 08-04-2010, 05:21 PM   #6
hanishmadan
LQ Newbie
 
Registered: Jan 2010
Posts: 8

Rep: Reputation: 0
the one I posted above will append the data into the file.
 
Old 08-05-2010, 12:10 AM   #7
wagaboy
Member
 
Registered: Jun 2010
Distribution: Ubuntu 10.04, Cent OS 5.5, CLE3
Posts: 51

Rep: Reputation: 21
Quote:
Just for understanding, the commands should write the output in the file as appending, isn't it?
yes, '-a' option is to append to an existing file. 'tee' is used to output to the terminal and the file at the same time.
 
Old 08-05-2010, 08:18 AM   #8
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
sorry guys,

but it is not working. I want it to run even if linux is closed, but as long as I close the window created after I type the command, it doesn't update anymore the file.
Is there a manner to make it working even if linux is closed?

Thank you
 
Old 08-05-2010, 08:43 AM   #9
diteshwithu
LQ Newbie
 
Registered: Aug 2010
Location: bangalore
Distribution: Redhat Linux
Posts: 3

Rep: Reputation: 0
there one way where you can use it after shutting down your system..
By using crontab command you can update ...this command automatically updates your requirements.


cmd is crontab -e(edit) <filename>
press enter
* * * * * watch --interval=1800 "pdsh -w comp[12,34,45] uptime >> log.txt.
(minutes) (hour) (date of month) (month) (date of week) (task)


The above command updates your requirement every day even after your system shutdown.
 
Old 08-05-2010, 08:47 AM   #10
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Dear diteshwithu,
let's say that practically speaking linux is on, it's working, since I am sending some jobs to a computer for making calculations, but I calse the interface for speaking with linux.
The command for updating the file each half an hour is:

Quote:
watch --interval=1800 "pdsh -w comp[12,34,45] uptime >> log.txt"
(I guess the guy forgot the closing ")

where does crontab enters?

Thank you
 
Old 08-05-2010, 09:23 AM   #11
hanishmadan
LQ Newbie
 
Registered: Jan 2010
Posts: 8

Rep: Reputation: 0
the simplest way is use command with nohup: -

open the terminal

run: - nohup watch --interval=1800 "pdsh -w comp[12,34,45] uptime >> log.txt&

now even if you close your terminal the command will keep on running.
 
Old 08-05-2010, 09:59 AM   #12
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Dear hanishmadan
are you sure of this command:
Quote:
- nohup watch --interval=1800 "pdsh -w comp[12,34,45] uptime >> log.txt&
Because it gives me a row like that:
>

and doesn't create any file

Thank you
 
Old 08-05-2010, 10:49 AM   #13
hanishmadan
LQ Newbie
 
Registered: Jan 2010
Posts: 8

Rep: Reputation: 0
why are you giving - before nohup... just use nohup and full command and & sign in the last
 
Old 08-05-2010, 11:04 AM   #14
mortain
LQ Newbie
 
Registered: Aug 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Dear hanishmadan,

probably I didn't give you all the information, anyway this is what I write and the output:

http://yfrog.com/58nohgp

Thanks

Antonio
 
Old 08-06-2010, 02:06 AM   #15
hanishmadan
LQ Newbie
 
Registered: Jan 2010
Posts: 8

Rep: Reputation: 0
Dear Mortain,

if you look at your command you are giving " at the begining of pdsh in your command, it has to be closed before you give redirection to the file or you finish the command .. so please verify your command once again and then run it.
 
  


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
Linux Watch vs BSD Watch blueCow *BSD 4 08-16-2009 06:35 PM
LXer: Uh Oh. Another Smooth Move from Microsoft: Watch out, Ruby. Watch out OSI. LXer Syndicated Linux News 0 07-31-2007 12:46 AM
netflix 'watch now' - watch streaming movies on my pc schneidz Linux - General 3 06-19-2007 09:34 AM


All times are GMT -5. The time now is 11:42 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