Skip to content

Instantly share code, notes, and snippets.

View rav94's full-sized avatar
🎯
Focusing

Ravindu Fernando rav94

🎯
Focusing
View GitHub Profile
@rav94
rav94 / remove-docker-dangling.timer
Created October 14, 2017 06:15
Systemd timer for remove-docker-dangling.service - To run in daily frequency
[Unit]
Description=Run remove-docker-dangling.service every 30 minutes
[Timer]
OnCalendar=*:0/30
@rav94
rav94 / remove-docker-dangling.service
Created October 14, 2017 06:13
Systemd Service file for removing Docker dangling images
[Unit]
Description=Removing Docker Dangling Images Cron Service
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/bin/docker rmi $(docker images --quiet --filter 'dangling=true')"
@rav94
rav94 / Error_Reporter_nohup.sh
Last active December 16, 2017 04:12
Shell script for reporting nohup.out general errors into specified email/s.
#!/bin/bash
#Check whether a temporary file exisits
if [ ! -e nohup_errors_log ];
#If not you are here
then
#Grep for the desired pattern within your log file to catch the Error and Save the content to a new temporary file
grep "\[[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\},[0-9]\{3\}\] ERROR" /home/ubuntu/ravindu/nohup.out | sort > nohup_errors_log
#Mail the recorded error list to the desired mail (You can mail it to multiple uses also)
mail -s "Error Log for nohup.out" [email protected] < nohup_errors_log