$ apt-get install vnstat
To create the cron job simply run this command
$ vnstat -u -i eth0
Replace eth0 with the interface you want to monitor
This creates a file in /var/lib/vnstat/
that collects the data for that interface. A cron job will run every 5 minutes to update the data.
vnstat without any argument,
$ vnstat
will give you a quick summary with the following info:
Database updated: Thu Jan 12 22:20:01 2006
ath0
received: 0.11 MB (nan%)
transmitted: 0.01 MB (nan%)
total: 0.12 MB
rx | tx | total
-----------------------+------------+-----------
today 0.11 MB | 0.01 MB | 0.12 MB
-----------------------+------------+-----------
estimated 0 MB | 0 MB | 0 MB