LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 03-10-2016, 03:37 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Process order of scripts


Does this script process the copying BEFORE it sends the second date to the file ?

Because my results are not true.

Quote:
Quote:
date "+ %m/%d/%y %r" >> Speed.txt
gxmessage -timeout 2 "Copying 819 Mb file to sdb2."
cp largefile /mnt/sdb2
date "+ %m/%d/%y %r" >> Speed.txt

03/10/16 03:31:30 PM
03/10/16 03:31:56 PM
26 seconds to copy a 819 Mb file to an external drive ??
 
Old 03-10-2016, 04:48 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,155

Rep: Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857
If the external drive was a usb it may have been asleep and needed to wake up before the copy could take place, also you would get better results when timing a command to use
Code:
time cp largefile /mnt/sdb2
as this gives the time the command took to run.
 
Old 03-10-2016, 04:51 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
As far as the cp program is concerned, the job is done. In reality, that data is sitting in the kernel's buffer cache and being flushed out to the disk in the background. If you've got a lot of memory, there can be gigabytes of data in those buffers. Run sync or unmount the filesystem to see how long the operation really takes.
 
Old 03-10-2016, 05:07 PM   #4
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks.
Quote:
TextFile='Speed.txt'

date "+ %m/%d/%y %r" >> $TextFile
gxmessage -timeout 2 "Copying largefile to sdb2."
time (cp largefile /mnt/sdb2) >> $TextFile 2>&1
echo ........................ >> $TextFile
#rm largefile
rm /mnt/sdb2/largefile
 
Old 03-10-2016, 06:52 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by Fixit7 View Post
Code:
TextFile='Speed.txt'

date "+ %m/%d/%y %r" >> $TextFile
gxmessage -timeout 2 "Copying largefile to sdb2."
time (cp largefile /mnt/sdb2) >> $TextFile 2>&1
echo ........................ >> $TextFile
#rm largefile
rm /mnt/sdb2/largefile
And the result of that is???

Note also that largefile might never be written to /mnt/sdb2. If you delete the file before the buffers have been flushed out, any pending writes are cancelled, and the data is never written to the drive. That happens a lot with short-lived files in /tmp, and is part of the reason that putting /tmp on a disk vs. putting /tmp in a tmpfs in RAM that is potentially swapped out to disk doesn't make a large difference in the amount of disk I/O that is performed.

Note: Please do not use [QUOTE] ... [/QUOTE] tags for purposes other than quoting other posts. It makes it hard to quote your content in a reply. Use [CODE] ... [/CODE] tags instead.
 
Old 03-10-2016, 09:25 PM   #6
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
So would a sync before the deletion flush all the buffers ?
 
Old 03-10-2016, 09:26 PM   #7
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I see no difference ?

Quote:
Originally Posted by Fixit7 View Post
So would a sync before the deletion flush all the buffers ?
Code:
code
 
Old 03-11-2016, 08:08 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by Fixit7 View Post
So would a sync before the deletion flush all the buffers ?
It would, but you have to include the time it takes for the sync to return. The cp command will still finish before the buffers are flushed, just as it did before.
Code:
time (cp largefile /mnt/sdb2; sync)
 
Old 03-11-2016, 10:46 AM   #9
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
So, there is no way to get an accurate reading.
 
Old 03-11-2016, 10:54 AM   #10
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
There is only .06 secs difference.

It looks like the buffers are flushed


Quote:
Time with largefile being deleted

03/11/16 10:48:10 AM

real 0m2.573s
user 0m0.000s
sys 0m0.387s

Time without large file being deleted

........................
03/11/16 10:49:13 AM

real 0m1.307s
user 0m0.010s
sys 0m0.317s
........................
Code:
TextFile='Speed.txt'

date "+ %m/%d/%y %r" >> $TextFile
gxmessage -timeout 2 "Copying largefile to sdb2."
time (cp largefile /mnt/sdb2) >> $TextFile 2>&1
# Write all buffered blocks to disk
echo ........................ >> $TextFile
sync
sleep 5
#rm largefile
#rm /mnt/sdb2/largefile
 
Old 03-11-2016, 11:13 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,016

Rep: Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342Reputation: 7342
you need to check the real time (see man time about the meaning real/user/sys)
 
Old 03-11-2016, 04:11 PM   #12
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Interesting, so the time is half when the file is not deleted.

I'll read up on real,user,sys.
 
  


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] change order of scripts in rc.M to accomodate nfs over wireless vdemuth Slackware 16 12-11-2011 05:36 PM
How do you control the order init.d scripts are started in SLES 10.2 64-Bit? j_unix Linux - Server 5 04-16-2009 12:42 PM
Help, how to find boot order of scripts/services? Avatar Linux - Server 4 07-30-2008 07:48 AM
Changing the process order smoscar_01 Linux - Newbie 2 09-30-2006 07:41 AM
SysV-Init scripts...change order during bootstrapping? tsw Mandriva 2 07-02-2004 08:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

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