Skip to content

Instantly share code, notes, and snippets.

View mtrunkat's full-sized avatar
💻
Hiding behind the keyboard

Marek Trunkát mtrunkat

💻
Hiding behind the keyboard
View GitHub Profile
@mtrunkat
mtrunkat / daemon.sh
Last active June 12, 2017 20:05
Run bash script forever with CRON with concurrency 1
#!/bin/bash
# Original: http://bencane.com/2015/09/22/preventing-duplicate-cron-job-executions/
#
# This script executes ./cmd_loop.sh and save process ID (PID) in file ./forever.pid.
# Everytime it's executed it checks for PID in ./forever.pid and if process is still
# running then exists with nonzero code. Otherwise it executes ./cmd_loop.sh.
PIDFILE=./forever.pid
@mtrunkat
mtrunkat / docker-host-ip.sh
Created January 9, 2017 19:23
Get IP address of host machine from docker container
#!/bin/bash
/sbin/ip route|awk '/default/ { print $3 }'
@mtrunkat
mtrunkat / waitforstring.sh
Last active December 27, 2016 13:55
Bash function that waits for string to appear in file.
#!/bin/bash
# Waits for string $2 to appear in the file $1.
# Meanwhile it is printing output of the file $1.
# If err or ERR string is find in the file $1 then exits with error code 1.
# Example use:
# waitforstring /var/log/myapp.log "MongoDB started"
function waitforstring {
local LAST_LINE=1
local READ_LOG