I finally figured out what I wanted to do. I searched around a bit for some way to log the print data in such a way that I could use it to tabulate printer usage by user, and I found this: http://savannah.nongnu.org/projects/printanalyze/. It's a really nice little script that reads the CUPS print_log and sorts the data all sorts of ways. I set up a cron job (command: crontab -e) which ran this program (PrintAnalyzer) as sudo and wrote the output to a file called print.log. So my crontab entry looks like:
Code:
00 * * * * sudo PrintAnalyzer > ~/print.log
. (If you're unsure what the 00s and stars do at the beginning, check out this helpful page.)
Finally, I created a script called printlogarchive, which I use to archive the print.log at the end of each month. (PrintAnalyzer does show cumulative data, so the hourly overwrites still show the previous print job info, but I wanted to have a per-month log as well.) The script is like this:
Code:
#!/bin/bash
dt=$( date +%y%m%d.%k%M )
mv print.log print_${dt}.log
mv print_${dt}.log ~/printlog_archive/
where "dt" is a variable of sorts built by the command "date", which in this case sets up a string with the two-digit year, month, and day, a ".", then the 24-hour time and minute. I added "printlogarchive" to the crontab as well, setting it to run once a month.
(I should also note that both of my scripts were moved to /usr/local/bin/ once they were finished so that they were executable from the command line without having to be in their directory and type a "./" in front of the command. And of course the file permissions were changed so that the file is executable.)
I tried to make this info newbie-friendly so that others can use this info, but let me know if you have questions!
-Dan
Bookmarks