Development

Get time taken to execute task in Ubuntu

To check and get a detailed response on how long a task took on your Ubuntu server you can use the time utility. Note that this is not the inbuilt time function.

Installing time can be done with:

sudo apt-get install time

Now you can time your script executions with

/usr/bin/time -v [TASKHERE]

Example to get size of the var directory

/usr/bin/time -v du -sh /var

returns

1.2G    /var
        Command being timed: "du -sh /var"
        User time (seconds): 0.01
        System time (seconds): 0.06
        Percent of CPU this job got: 26%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.31
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 3000
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 387
        Voluntary context switches: 8227
        Involuntary context switches: 3
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

Giving you many types of timings for the task.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago