LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with watch function (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-watch-function-824159/)

mortain 08-04-2010 01:11 PM

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

wagaboy 08-04-2010 02:09 PM

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"

mortain 08-04-2010 03:10 PM

Thank you very much!

hanishmadan 08-04-2010 04:40 PM

you can do it like below also: -

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

mortain 08-04-2010 04:59 PM

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

hanishmadan 08-04-2010 05:21 PM

the one I posted above will append the data into the file.

wagaboy 08-05-2010 12:10 AM

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.

mortain 08-05-2010 08:18 AM

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

diteshwithu 08-05-2010 08:43 AM

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.

mortain 08-05-2010 08:47 AM

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

hanishmadan 08-05-2010 09:23 AM

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.

mortain 08-05-2010 09:59 AM

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

hanishmadan 08-05-2010 10:49 AM

why are you giving - before nohup... just use nohup and full command and & sign in the last

mortain 08-05-2010 11:04 AM

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

hanishmadan 08-06-2010 02:06 AM

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.


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