User Tools

Site Tools


shell2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
shell2 [2020/12/09 08:30] – [Application Memory Usage] dblumeshell2 [2023/05/17 09:47] (current) – [Protips for find] dblume
Line 292: Line 292:
 # at 3 in the morning on Mondays, delete files older than 30 days # at 3 in the morning on Mondays, delete files older than 30 days
 0 3 * * 1 find $HOME/.vim/backup/ -type f -mtime +30 -delete 0 3 * * 1 find $HOME/.vim/backup/ -type f -mtime +30 -delete
 +</code>
 +
 +====== Calculate web server bandwidth ======
 +
 +Use ''awk'' to add up a column from Apache logs:
 +
 +<code>
 +$ sudo cat /var/log/httpd/access_log | awk '{SUM+=$10}END{print SUM/1024/1024}'
 +0.855597
 </code> </code>
  
Line 551: Line 560:
   find lib -type f -name \*.so\* -exec sh -c 'objdump -p "$1" | grep "NEEDED.*libz"' - {} \; -print   find lib -type f -name \*.so\* -exec sh -c 'objdump -p "$1" | grep "NEEDED.*libz"' - {} \; -print
      
-Note that you can pass -print (or -and -print) after a -exec argument. Also, the " - " is just a placeholder for $0 (usually the command name, in this case "sh"), we want $1 to be {}. It outputs results like:+Note that you can pass -print (or -and -print) after a -exec argument. You can also use -printf, ex., ''-printf %%"%%\t%f\n%%"%%''. Also, the " - " is just a placeholder for $0 (usually the command name, in this case "sh"), we want $1 to be {}. It outputs results like:
  
     NEEDED               libz.so.1     NEEDED               libz.so.1
   lib/libprotoc.so.13.0.2   lib/libprotoc.so.13.0.2
  
 +Tip: tar up the last day's worth of log files:
 +
 +  find . -mtime -1 -name \*.log -print0 | tar -jcvf logs.tar.bz2 --null -T -
 ====== Additional Keywords ====== ====== Additional Keywords ======
  
 Linux, Unix, *nix Linux, Unix, *nix
shell2.1607531427.txt.gz · Last modified: 2023/04/12 20:44 (external edit)