- 论坛徽章:
- 0
|
题目:
Write a script that upon invocation shows the time and date, lists all logged-in users, and gives the
system uptime. The script then saves this information to a logfile.
以下是我写的。
#!/bin/bash
#Program:
# Program will show the date, time, current logged-in users and system uptime.
#+The save these information to a logfile.
cat /dev/null > /tmp/logit.log
echo -e "\nDate:`date +%F`" 2>> /tmp/logit.log
echo -e "Time: `date +%r`\n" 2>> /tmp/logit.log
echo -e "***********************Logged-in users************************************* \n" 2>> /tmp/logit.log
w 2>> /tmp/logit.log
echo -e "\n************************************************************************* \n" 2>> /tmp/logit.log
echo -e "How long the system has been running?\n" 2>> /tmp/logit.log
uptime 2>> /tmp/logit.log
echo -e "\n" |
|