Execute the system command and write the shell script that writes the output to the log file,
This is probably the requirement. Run the usysfault command on the aix system to retrieve the fault light information. However, it seems that only the root user can execute this command. If other users execute this command, an error is reported. I tried every means to grant permissions and ended up failing. So I thought of writing shell scripts to write the results to the log file using the root user, and then we could read the file to get the data, we don't need to execute any commands that we don't want to execute.
The shell script is as follows:
! /Usr/bashwhile true # execute do {date + "% Y-% m-% d % H: % M: % S "# Get the current date and time uname # command to be executed}> patrol. log # output to log sleep 5 # execution cycle is 5 seconds done
This script stores the host system type and time in the log file. logs are stored in overwrite mode, not append mode. There is always only one record.
Run the following command:
Sh patrol. sh &
To run the script in the background to retrieve the number of times.