LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Time duration from one command to another (https://www.linuxquestions.org/questions/linux-newbie-8/time-duration-from-one-command-to-another-896139/)

niharikaananth 08-08-2011 02:59 AM

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.

angel115 08-08-2011 03:21 AM

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.

paulmarc 08-08-2011 04:28 AM

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...

jdkaye 08-08-2011 04:40 AM

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


All times are GMT -5. The time now is 09:17 PM.