Assignment 5221238
Assignment 5221238
4. Write a script that uses the "lshw" command to generate a report of the system hardware. The
script should output the report to a file and include information on the CPU, memory, storage
devices, and other hardware components.
#!/bin/bash
# Define the output file path and name
output_file="system_hardware_report.txt"
# Run lshw and redirect the output to the specified file
sudo lshw > "$output_file"
# Check if lshw was executed successfully
if [ $? -eq 0 ]; then
echo "System hardware report generated and saved to $output_file"
else
echo "Error: Failed to generate the system hardware report"
fi
Create a simple script that prints the current date and time to a file. Schedule script execution
every 5 minutes. Check the task execution using the system operation logs.
#!/bin/bash
# Define the output file
output_file="/labcaCO5/2023Kanat" # Replace with the actual file path
# Get the current date and time and append it to the file
date "+%Y-%m-%d %H:%M:%S" >> "$output_file"