I learned today how to show the time your Linux system needed to execute a command. This allows you to better monitor your performance and distribute the tasks accordingly.
The command
Just type in the command line time and then a corresponding command. So the structure would look in example like this:
time dir
For example, the above example lists the contents of the current directory and immediately below it shows me how long the system needed to complete this task. The result looks like this:
- real / elapsed 0m0,017s
Is the time used from pressing the Enter key to the result. - user 0m0,002s
The time how long the program has been running. - sys 0m0,010s
The kernel time. This means that this is the time, the command used to for example reading files.
My usage
I have installed Nextcloud on my Raspberry Pi, and this software, with my configurations, has two commands, that I need to run at least once a day. These commands sometimes take several hours, and I have to have the exact time to know how many hours I’m supposed to have the orders executed at night.
However, I can not enter a command and sit in front of the computer until it has completed the tasks, but it would be convenient if I put in a command in the morning and see how long it took in the evening. A command is called for example:
time sudo -u www-data php /var/www/html/cloud/occ files:scan --all
This scans all my folders in the cloud and makes them available in the app. For example, this will take two hours, so I’ll let it run at 12 o’clock at night and the next command at 3 o’clock to be on the safe side.