IBM Support

Calculating Uptime on the IBM i

Question & Answer


Question

How do you calculate the Uptime for an IBM i Server.

Answer

The IBM i Operating System does not have a command to calculate the Uptime of the Server, however, the following SQL can calculate the Uptime using the TIMESTAMPDIFF scalar function by retrieving the time and date of the start of the SCPF job. 
Using the RUN SQL Scripts tool, run the following SQL Statement:
 
SELECT JOB_NAME,
       JOB_ENTERED_SYSTEM_TIME,
       TIMESTAMPDIFF(2, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime_seconds,
       TIMESTAMPDIFF(4, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime_minutes,
       TIMESTAMPDIFF(8, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime_hours,
       TIMESTAMPDIFF(16, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime__days,
       TIMESTAMPDIFF(32, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime_weeks,
       TIMESTAMPDIFF(64, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime__months,
       TIMESTAMPDIFF(256, CAST(CURRENT TIMESTAMP - JOB_ENTERED_SYSTEM_TIME AS CHAR(22))) AS uptime__years
       
    FROM TABLE (
            QSYS2.ACTIVE_JOB_INFO(JOB_NAME_FILTER => '*ALL', DETAILED_INFO => 'ALL')
        )
    WHERE JOB_NAME = '000000/QSYS/SCPF'
image-20240216082651-1

More information on the TIMESTAMPDIFF scalar function:

TIMESTAMPDIFF Scalar Function

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHjAAM","label":"Job and Work Management"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;7.4.0;7.5.0"}]

Document Information

Modified date:
16 February 2024

UID

ibm17114773