mirror of
				https://github.com/kevinveenbirkenbach/dmesg-continuous-logger.git
				synced 2025-11-03 19:38:00 +00:00 
			
		
		
		
	Create capture_dmesg.sh
This commit is contained in:
		
							
								
								
									
										21
									
								
								capture_dmesg.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								capture_dmesg.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Specify the log file name
 | 
			
		||||
LOGFILE="dmesg_continuous.log"
 | 
			
		||||
 | 
			
		||||
# Function to cleanup on exit
 | 
			
		||||
cleanup() {
 | 
			
		||||
    kill $DMESG_PID
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Start capturing dmesg in the background
 | 
			
		||||
dmesg -w > "$LOGFILE" &
 | 
			
		||||
DMESG_PID=$!
 | 
			
		||||
 | 
			
		||||
# Trap to cleanup on script exit
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
 | 
			
		||||
# Keep the script running until manually stopped
 | 
			
		||||
while true; do
 | 
			
		||||
    sleep 1
 | 
			
		||||
done
 | 
			
		||||
		Reference in New Issue
	
	Block a user