LinuxQuestions.org
Help answer threads with 0 replies.
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-08-2011, 02:59 AM   #1
niharikaananth
Member
 
Registered: Aug 2011
Posts: 58

Rep: Reputation: Disabled
Time duration from one command to another


Hi. I have made a shell script as below to find that how much time is taking between one command to another.
echo weekly backup started `date '+%Y-%m-%d/%k-%M'` > /var/log/backup/weekly.log
tar -cjvf something.tar.bz2 /directory
echo weekly backup completed `date '+%Y-%m-%d/%k-%M'` >> /var/log/backup/weekly.log
If I cat the content of /var/log/backup/weekly.log file the actual time is taken 5 hours 30 minutes for compressing and given 38GB *.bz2 file.
But for sending that 38GB *.bz2 file to some other server it is taking around only 25 minutes. for that the shell script as below
echo weekly backup sending to someserver `date '+%Y-%m-%d/%k-%M'` > /var/log/backup/nfsweekly.log
scp /directory/*.bz2 root@IP_Addr:/directory
echo weekly backup sent to someserver `date '+%Y-%m-%d/%k-%M'` >> /var/log/backup/nfsweekly.log
But I found only 29GB size in another server instead of 38GB. So there is a suspection of 2nd shell script, becuase if I realy use scp command insted of script it will take more than hour. In another server lot of free space is there where I am sending *.bz2 file. Although the file size is only 29GB instead of 38GB. So how can I made changes that only then that 3rd command(echo weekly backup sent to someserver `date '+%Y-%m-%d/%k-%M'` >> /var/log/backup/nfsweekly.log) should execute when 2nd(scp /directory/*.bz2 root@IP_Addr:/directory) command is successfully completed.
 
Old 08-08-2011, 03:21 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
Sorry but I've some difficulty to get what you are doing.

1. You create a tar.bz2 file. (which is one file only right? or you split the file?)
2. Then, I lost you...


Can you please clarify your issue?

Thanks,
Angel.

Please number your step so it will be easier to follow you.

Last edited by angel115; 08-08-2011 at 03:23 AM.
 
Old 08-08-2011, 04:28 AM   #3
paulmarc
LQ Newbie
 
Registered: Jul 2011
Distribution: Fedora
Posts: 11

Rep: Reputation: 4
Post Can time commands separately

You can always use the time command to get the exact time taken by a command:
Code:
time tar -cjvf something.tar.bz2 /directory
This would output the time given to compress your directory.
Just prepend time before the command you want to clock...
 
Old 08-08-2011, 04:40 AM   #4
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Code:
echo weekly backup started `date '+%Y-%m-%d/%k-%M'` > /var/log/backup/weekly.log
tar -cjvf something.tar.bz2 /directory
echo weekly backup completed `date '+%Y-%m-%d/%k-%M'` >> /var/log/backup/weekly.log
If I cat the content of /var/log/backup/weekly.log file the actual time is taken 5 hours 30 minutes for compressing and given 38GB *.bz2 file.
But for sending that 38GB *.bz2 file to some other server it is taking around only 25 minutes. for that the shell script as below
Code:
echo weekly backup sending to someserver `date '+%Y-%m-%d/%k-%M'` > /var/log/backup/nfsweekly.log
scp /directory/*.bz2 root@IP_Addr:/directory
echo weekly backup sent to someserver `date '+%Y-%m-%d/%k-%M'` >> /var/log/backup/nfsweekly.log
If you are posting scripts longer than one line please bracket them using the code ... /code surrounded by square brackets. That makes things easier to read as you can see from the above example.
ciao,
jdk
 
  


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] Does 'time' run the internal time command or the external one? stf92 Linux - Newbie 8 06-06-2011 04:11 AM
time command returns too much of system time pvouzis Linux - General 6 08-24-2009 01:35 AM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
computing time duration tmaxx Linux - General 1 04-29-2008 08:37 PM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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