How to check the execution time of your bash script?

How to check the execution time of your bash script?

Have you heard about server cron? Cron’s are mentioned as a utility used in Linux which runs in your server as script or command. It doesn’t expect your approval for command execution so, it runs automatically without interruption. The only need from your end is to set the date and time for the execution of cron’s in your server. In this server cron, you would have a bash script that works for a long time. You can’t guess the bash running script in server cron. So, it’s just to check the bash script execution time in a detailed analysis.

It is not possible to find the execution time from cron directly but instead, you have a choice to use bash variables to find the execution time totally. To check the status of cron execution go to “var” folder and then select “log” for checking cron. It’s tough to find the execution time but you have an option like using bash in Linux with SECONDS built-in variable. It counts the shell start and keeps on finding the seconds in execution. But don’t forget to keep the script as 0 before starting the work. The value assigned to the sum will be equal to the work returned with value. It is called the SECOND variable where the time spent totally.

You need to save the file after generating the sequence using the command “seq”. Use SECONDS built-in variable for cron checking time.

Here’s the sample one:

1611146939658.png


Sample of cron:

1611146947203.png


The displayed output is below-mentioned:

1611146954441.png


Another sample output:

1611146963659.png


We have said it already; crons usually run automatically in the background. Of course! You need to get a notification after cron execution right! So, the choice is yours now! Set the alert in email mode for getting the status of the cron once if it gets completed. But still, there are more ways for finding the total time cron execution. Identifying the ways is the difficult phase here! We have given you one solution and hope, it would definitely help you.
Author
bhawanisingh
Views
359
First release
Last update
Rating
0.00 star(s) 0 ratings
Top