LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-01-2021, 12:28 PM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Question Watch Command Options?


Hi all,
I find the Watch command very useful for monitoring the progress of large image files being copied over. However, the default output is in bytes and I would prefer (*much* prefer) to have it divided by 10^9 so I get to see gigabytes instead. What is the correct switch to use for this, please?
Thanks!
 
Old 08-01-2021, 01:35 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,511

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
'man watch' ought to help you find out how to do it.
 
Old 08-01-2021, 05:51 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The watch command doesn't output bytes or gigabytes. In your case, the output probably comes from the command that it watches, such as dd. To help you, we would need to know how you use watch.
 
Old 08-01-2021, 05:58 PM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,650

Rep: Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565

Commands that deal with bytes often have a -h/--human-readable option.

rsync (which is commonly used to copy large files) has this option, and also has -v/--verbose and -P/--progress options that may avoid the need for watch.

(If you're on the receiving end and using watch with ls, you will find that command also has a -h/--human-readable option.)

 
Old 08-01-2021, 06:24 PM   #5
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
I'm using it for monitoring the progress of dd as it images a partition:
Code:
watch /mnt/sdb1/imagefilename.img
Even though the partition is 'only' 149Gb in size it's *really* hard to tell whether it's at 14.9Gb or 149Gb. I'd assumed like df for 'disk free' it would have the human-friendly -h switch but it seems it doesn't.
 
Old 08-01-2021, 08:58 PM   #6
SW64
Member
 
Registered: May 2014
Distribution: Slackware
Posts: 262

Rep: Reputation: 123Reputation: 123
Quote:
watch /mnt/sdb1/imagefilename.img
Your watch example makes no sense. For one, it's incomplete. It is missing 'dd' if you meant to include that and either an input option or an output option, depending on what you want to do with that image. Two, there is nothing to watch in a dd command if its command does not include the status option. 'df -h' is a better use of the watch command. dd not saying anything all the way to the prompt is a good thing but that's unnerving for a lot of people, lol.

Depending on its version, dd has progress status. Here's an example with the status option.
Code:
dd if=/dev/sda of=/dev/sdb bs=4096 status=progress
Because of your account name and your watch example, before you do carry out any more dd commands, you need to do the following:
  • Put in 'man dd' in your terminal and hit return. Read carefully.
  • Search for 'linux dd' with your favorite search engine and read carefully a few articles about dd from the results.
 
1 members found this post helpful.
Old 08-02-2021, 01:51 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,386
Blog Entries: 3

Rep: Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775
Quote:
Originally Posted by Completely Clueless View Post
I'm using it for monitoring the progress of dd as it images a partition:
Code:
watch /mnt/sdb1/imagefilename.img
Even though the partition is 'only' 149Gb in size it's *really* hard to tell whether it's at 14.9Gb or 149Gb. I'd assumed like df for 'disk free' it would have the human-friendly -h switch but it seems it doesn't.
You probably mean something like this:

Code:
watch -n 1 -- ls -lh /mnt/sdb1/imagefilename.img
That will review the size of imagefilename.img every second.
 
Old 08-02-2021, 05:09 AM   #8
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,511

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
No need to use watch at all. Simply adfd 'status=progress' to the dd command.
 
Old 08-02-2021, 06:25 AM   #9
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Completely Clueless View Post
I'm using it for monitoring the progress of dd as it images a partition:
Code:
watch /mnt/sdb1/imagefilename.img
This is not the watch that I know. The one I mean requires a command, not a filename.

I would do something like this:
Code:
watch du -h /mnt/sdb1/imagefile.img
or
Code:
watch ls -sh /mnt/sdb1/imagefile.img
or simply
Code:
dd ... of=/mnt/sdb1/imagefile.img status=progress
(just noticed that I am not the first to suggest progress)

Last edited by berndbausch; 08-02-2021 at 06:28 AM.
 
Old 08-02-2021, 07:48 AM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Okay, thanks guys. Seems I should forget about Watch and use status=progress with dd instead. But.... will the same problem arise again or will this genuinely provide a more readable output?
 
Old 08-02-2021, 07:50 AM   #11
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
I should add there was no such 'progress' option with dd in the Linux Commands Bible I have (dated 2008) so it seems it's something that's been built into dd as an update at some time later.
 
Old 08-02-2021, 11:22 AM   #12
SW64
Member
 
Registered: May 2014
Distribution: Slackware
Posts: 262

Rep: Reputation: 123Reputation: 123
The 'status=progress' option was added "recently", yes. I first learned about it here at linuxquestions.org.

I see from the posts after mine that you probably meant to have 'ls' instead of 'dd' in your 'watch' example. Now that makes more sense. 'watch' doesn't covert whatever command you've given it to something else. It just execute your commands and display the result at interval. That's all it does. So if you want to see a command printout in a human-readable form, you need to hit the man pages (or search online) of whatever command you're giving 'watch' to do and find that switch. It's often the '-h' switch but not always.

'watch' is a useful tool to have. Keep at it til you've figured it out.
 
Old 08-02-2021, 11:31 AM   #13
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
Quote:
Originally Posted by SW64 View Post
The 'status=progress' option was added "recently", yes.
GNU coreutils 8.24 (Jul 2015).
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Watch vs BSD Watch blueCow *BSD 4 08-16-2009 05:35 PM
LXer: Uh Oh. Another Smooth Move from Microsoft: Watch out, Ruby. Watch out OSI. LXer Syndicated Linux News 0 07-30-2007 11:46 PM
netflix 'watch now' - watch streaming movies on my pc schneidz Linux - General 3 06-19-2007 08:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:30 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
Open Source Consulting | Domain Registration