SOLVED - Using bc in Bash script
Charles Howse
chowse at charter.net
Thu Aug 14 14:54:11 PDT 2003
Got it going.
Instead of running daily_report from cron, I will now run the following:
------------------------------------------------------------------------
-
#!/usr/local/bin/bash
# Time and run the Daily_report
\time -ho /root/tmp.time ~/bin/daily_report
cat /root/tmp.time | cut -f 2 | cut -c 1-4 >> /root/daily.log
cat /root/daily.log | mail -s "Daily Report from Larry" charles
------------------------------------------------------------------------
--
Here's what I get in the mail, note the very last line is the output
from \time:
Daily Report for Larry for Thursday, August 14 2003.
********************************************
Report begun at: 16:44
Current Operating System
********************************************
FreeBSD 4.8-RELEASE
Uptime
********************************************
4:44PM up 1 day, 5:57, 1 user, load averages: 0.00, 0.00, 0.00
Cron Jobs
********************************************
58 0 * * * /root/bin/daily_report
Logins today
********************************************
root ttyv1 Thu Aug 14 12:02 - 15:38
(03:35)
root ttyv1 Thu Aug 14 10:48 - 11:56
(01:07)
root ttyv0 Thu Aug 14 08:40 still
logged in
Accounts with uid = 0 (Superusers)
********************************************
root
toor
Accounts that have a valid shell
********************************************
root:*:0:0::/root:/usr/local/bin/bash
charles:*:1001:1001:Charles Howse:/home/charles:/usr/local/bin/bash
Disk Free space
********************************************
Filesystem Size Used Avail Capacity Mounted on
/dev/ad0s1a 98M 45M 45M 50% /
/dev/ad0s1f 1.8G 346M 1.3G 20% /usr
/dev/ad0s1e 197M 1.0M 180M 1% /var
/dev/ad3s1e 7.8G 1.1G 6.1G 15% /disk2
procfs 4.0K 4.0K 0B 100% /proc
Netstat -an results
********************************************
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address
(state)
tcp4 0 0 *.139 *.*
LISTEN
tcp4 0 0 *.445 *.*
LISTEN
tcp4 0 0 127.0.0.1.25 *.*
LISTEN
tcp4 0 0 *.110 *.*
LISTEN
udp4 0 0 192.168.254.3.138 *.*
udp4 0 0 192.168.254.3.137 *.*
udp4 0 0 *.138 *.*
udp4 0 0 *.137 *.*
udp4 0 0 127.0.0.1.123 *.*
udp4 0 0 192.168.254.3.123 *.*
udp4 0 0 *.123 *.*
udp4 0 0 *.514 *.*
udp6 0 0 *.514 *.*
Active UNIX domain sockets
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
ca1f5be0 dgram 0 0 0 ca1d5f00 0 ca1f5d20
ca1f5d20 dgram 0 0 0 ca1d5f00 0 ca1f5dc0
ca1f5dc0 dgram 0 0 0 ca1d5f00 0 ca1f5f00
ca1f5f00 dgram 0 0 0 ca1d5f00 0 0
ca1d5f00 dgram 0 0 ca1cfdc0 0 ca1f5be0 0
/var/run/log
Status of network interfaces
********************************************
tx0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 192.168.254.3 netmask 0xffffff00 broadcast 192.168.254.255
inet6 fe80::2e0:29ff:fe11:ff8a%tx0 prefixlen 64 scopeid 0x1
ether 00:e0:29:11:ff:8a
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
inet 127.0.0.1 netmask 0xff000000
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
Last modified
********************************************
Aug 14 16:44
Elapsed time in seconds
********************************************
0.27
Thanks,
Charles
More information about the freebsd-questions
mailing list