January 2004
Intermediate to advanced
368 pages
7h 25m
English
While every ISP offers relatively expensive unlimited-use dial-up accounts, you might not realize that many ISPs also have very low-cost monthly dial-up accounts if your usage stays below a certain number of hours of connect time in a given month. The problem is, how do you calculate your total connection time on a Unix system? Let's have a look. . . .
#!/bin/sh # connecttime - Reports cumulative connection time for month/year entries # found in the system log file. For simplicity, this is an awk program. log="/var/log/system.log" # this is just /var/log/system on some machines tempfile="/tmp/$0.$$" trap "rm $tempfile" 0 cat << 'EOF' > $tempfile BEGIN { lastmonth=""; sum = 0 } { if ( $1 != ...Read now
Unlock full access