Jobs - Status in Percentage

Hello,

when running a cron job, the jobs page list the running task and shows the status in percentage (as shown in the attached screenshot).

How does TrueNAS get this status and how can a script that runs as cron job, report its status correctly to TrueNAS?

Thanks a lot in advance,

Thomas

This is something that no machine is capable of doing. Not exactly. It’s continous guessing. Like copy status bars.

        job.set_progress(10, 'Executing Cron Task')

        cp = run_command_with_user_context(cron_cmd, cron_task['user'], callback=job.logs_fd.write)

        job.set_progress(85, 'Executed Cron Task')

10% in this case means “Executing Cron Task”. Since the user-provided script is entirely opaque to us, we have no idea when it will complete. Maybe it will sleep for 100 years, we will still show it as 10%. If you want better reporting you’ll need to write your own status for your scripts to some file and check that.

Ok, I am getting the point that the 10% information is of no value when running a cron job. So, why is TrueNAS not simply showing the runtime of the script so far or simply showing no percentage value?
For me, a “wrong” percentage is worse than no value at all.

I like this, show the runtime. This makes much more sense.

2 Likes