You can use the Process pane in the Utilities toolbar item to turn on the process accounting option, which is turned off by default.
If this option is turned on, macOS will save all processes run by all the users of the computer in a file (/private/var/account/acct). You can also display and delete the contents of this file.
Important: Many processes are in use, so this file can become very large. You should delete its contents occasionally. This operation is launched while deleting the logs.