26 lines
		
	
	
		
			540 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			540 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								#!/bin/bash
							 | 
						||
| 
								 | 
							
								#logcheck [days] [location]
							 | 
						||
| 
								 | 
							
								re='^[0-9]+$'
							 | 
						||
| 
								 | 
							
								days=2
							 | 
						||
| 
								 | 
							
								location=/tmp
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# If there is a second arg, use it as the location
							 | 
						||
| 
								 | 
							
								if ! [ -z "$2" ]; then 
							 | 
						||
| 
								 | 
							
									location=$2
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# If first arg is a number, then set days.
							 | 
						||
| 
								 | 
							
								if ! [ -z "$1" ]; then 
							 | 
						||
| 
								 | 
							
									if [[ $1 =~ $re ]] ; then	
							 | 
						||
| 
								 | 
							
										days=$1
							 | 
						||
| 
								 | 
							
									else
							 | 
						||
| 
								 | 
							
										location=$1
							 | 
						||
| 
								 | 
							
									fi;	
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								echo "Log file: $location/log$(date +'%m%d%y')"
							 | 
						||
| 
								 | 
							
								find /var/log/ -mtime -$days -print -exec sh -c 'cat "{}"  | tai64nlocal | egrep -i "useless|warn|fail|error|disable|remov|unable|exit"' \; > "$location/log$(date +'%m%d%y')" 2>&1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exit 0
							 | 
						||
| 
								 | 
							
								
							 |