1

I am writing a shell script in abc.sh

echo $(date)
openssl aes-256-cbc -a -salt -in abc.zip -out abc.zip.enc 
echo $(date)

It is showing the time at both start and end of the process, but I want the exact amount of time taken to complete such process.

muru
  • 197,895
  • 55
  • 485
  • 740

1 Answers1

3

Use time command before your command:

time command

What does it do?

time (1) - run programs and summarize system resource usage

For your situation:

time openssl aes-256-cbc -a -salt -in abc.zip -out abc.zip.enc 

It will output something like:

real    0m2.199s
user    0m0.008s
sys     0m0.008s

The time in user section is what you are looking for, the time that user space worked on your process.

The sys is related to kernel and the real is what you are getting right now with your echo solution, your clock time from running to the end with the time you spend for entering the password.

muru
  • 197,895
  • 55
  • 485
  • 740
Ravexina
  • 55,668
  • 25
  • 164
  • 183