Friday, October 29, 2021

[SOLVED] How to get execution time of a specific script that is running, but in the background?

Issue

I have a script (php) that runs in the background (nohup php script...), but for some reason it ends up stopping, as this script only produces 'logs' when it has something to do.

I need 'something' to know how long it was running until the moment it stopped , but I didn't want to let the responsibility for this script to 'make log' every second, I'd like some way to see how long time it was running, but so that I can "close the all terminal" screens and when reconnecting to the terminal, I can query the stop time, or even the execution time and time the script stopped.


Solution

You can add execution time nohup log by execution the command on this way:

nohup /usr/bin/time php script...


Answered By - Romeo Ninov