Viewing Operation History
Use the pkg history command to view pkg command history that modifies the image. Commands such as pkg search, pkg refresh, pkg publisher, pkg facet, and pkg property are not recorded in pkg history, but commands such as pkg set-publisher, pkg change-facet, and pkg set-property are recorded in pkg history. Sometimes pkg history shows multiple operations executed for one command entered. For example, pkg refresh --full displays refresh-publishers and rebuild-image-catalogs in pkg history output.
To quickly check the time of the last image modification or configuration change, check the time stamp of the /var/pkg/modified file. The /var/pkg/modified file is an empty file whose time stamp is updated every time an operation occurs that modifies the image. For more information about what changed, use the pkg history command with the -t option as shown in Example 5-6.
By default, the pkg history command displays the following information:
-
The start time of the operation
-
The name of the operation, for example,
install -
The client, for example,
pkg -
The outcome of the operation:
SucceededorFailed
Use options to display more information or more precise information.
-
-l -
Display the following information in addition to the default information:
-
The version of the client
-
The name of the user who performed the operation
-
Whether a new BE was created
-
The time the operation completed
-
The complete command that was issued
-
Any errors that were encountered while executing the command
-
Complete FMRIs of changed packages for operations such as
update
-
-
-nnumber -
Display only the specified number of most recent operations.
$ pkg history -n4 START OPERATION CLIENT OUTCOME 2013-08-06T16:32:03 fix pkg Succeeded 2013-08-06T16:41:47 revert pkg Succeeded 2013-08-06T17:56:22 set-property pkg Succeeded 2013-08-06T17:56:53 unset-property pkg Succeeded -
-ocolumn[,column]... -
Display output using the specified comma-separated list of column names. See the list of column names in the
pkg(1) man page.$ pkg history -o start,time,operation,outcome -n4 START TIME OPERATION OUTCOME 2013-08-06T16:32:03 0:00:27 fix Succeeded 2013-08-06T16:41:47 0:00:43 revert Succeeded 2013-08-06T17:56:22 0:00:00 set-property Succeeded 2013-08-06T17:56:53 0:00:00 unset-property Succeeded -
-ttime|time-time[,time|time-time]... -
Log records for a comma-separated list of time stamps, formatted with
%Y-%m-%dT%H:%M:%S(see thestrftime(3C) man page). To specify a range of times, use a hyphen (-) between a start and finish time stamp. The keywordnowis an alias for the current time. If the time stamps specified contain duplicate time stamps or overlapping date ranges, only a single instance of each duplicate history event is displayed. -
-N -
Use the
-Noption to display any release note text for the operation. The-Noption cannot be used with the-ooption. If you specify the-voption in an install or update operation in which some of the packages being installed have release notes, the operation output displays the release notes. If the operation installs into a new BE, the operation output provides a path to a release notes file in/tmpin the current BE. When you boot into the new BE, the release notes are in/usr/share/doc/release-notes, or you can use the-Noption to view the release notes as shown in the following command:$ pkg history -N -n 1If the operation that installed release notes is not the last
pkgoperation you performed in this BE, use a larger number for the-nargument or use the-toption to identify thepkgoperation that installed the release notes as shown in the following command:$ pkg history -N -t 2013-07-17T08:31:23
Example 5-6 Getting Information About Image Change
The following command uses the /var/pkg/modified file to show the last time this image was modified:
$ ls -l /var/pkg/modified
-rw-r--r-- 1 root root 0 Jul 22 10:54 /var/pkg/modified
You might not need any more information. You might only need to know whether the image has changed since the last time you performed a certain operation.
The following example shows how you can use the pkg history command to get more information.
The following command shows pkg operations that occurred within a specified range of time:
$ pkg history -t 2016-07-22T10:54:00-2016-07-22T10:55:00
START OPERATION CLIENT OUTCOME
2016-07-22T10:54:05 update-publisher pkg Succeeded
2016-07-22T10:54:06 refresh-publishers pkg Succeeded
2016-07-22T10:54:53 rebuild-image-catalogs pkg Succeeded
The following command shows more information about a particular operation from the preceding list:
$ pkg history -lt 2016-07-22T10:54:05
Operation: update-publisher
Outcome: Succeeded
Reason: None
Client: pkg
Version: 77d785eb851b
User: admin (100)
Boot Env.: 103_104.34291
Boot Env. UUID: 1831b116-361f-4ef0-9406-851c446ec4c2
New Boot Env.: None
New Boot Env. UUID: (None)
Snapshot: (None)
Start Time: 2016-07-22T10:54:05
End Time: 2016-07-22T10:55:25
Total Time: 0:01:20
Command: /usr/bin/pkg set-publisher -g /var/share/pkg/repositories/solaris solaris
Release Notes: No
Start State:
None
End State:
None
Example 5-7 Purging History Information
Use the pkg purge-history command to delete all existing history information.
$ pkg purge-history