Get Days in a month from a bash script

Useful listing of days in a month to populate directories or run scripts for backing up getting the correct dates of days in a month and year.     YEAR=2020 MONTH=2 for DAY in $(DAYS=`cal $MONTH $YEAR | awk ‘NF {DAYS = $NF}; END {print DAYS}’` && seq -f ‘%02G’ $DAYS) ;do DATE=”$YEAR-$MONTH-$DAY” echo $DATE…

incrond cannot exec process: No such file or directory

Inside you incrontabs, you must leave *only* 1 space between the <path> <mask> <cmd>. If you leave 2 or more spaces, then the 2nd (and more) spaces will be considered part of the <mask> or <cmd> and it will fail… I was leaving 2 spaces between <mask> and <cmd>, and incron did not work and in…

Cool chkconfig replacement for Ubuntu

Hi,   Ubuntu does not carry chkconfig any more .. besides the standard update-rc.d apache2 defaults or update-rc.d apache2 remove There is a cool tool called : sysv-rc-conf. This tool can be installed using : sudo apt-get install sysv-rc-conf On its own the command opens a cool ncurses interface like this :      …

Snapshot backup using cp -al and rsync

This script requires genuine cp -al capable gnu and rsync commands together with a hardlink capable FS + OS.     #!/bin/bash [ $# -ne 2 ] && echo “Incorrect usage : $0 <source path> <target path>” && exit 128 ; SOURCEFOLDER=$1 TARGETFOLDER=$2 SF_LEN=${#SOURCEFOLDER}-1 TF_LEN=${#TARGETFOLDER}-1 #echo “Last character in source folder is ${SOURCEFOLDER:SF_LEN}” if […

Progress bar in bash

a=0; for i in `cat $FOLDERLIST` do ((a++)) percentage=`awk -v a=$a -v b=$NUMBEROFFOLDERS 'BEGIN {printf "%3.0f", a / b * 100; exit } '` arrow=`printf '=%.0s' $(seq 1 $percentage)` headed=`printf '%s%s' $arrow '>'` paddedarrow=`printf '%-102s' $headed` echo -ne "$paddedarrow $a/$NUMBEROFFOLDERS [$percentage] \r " done echo njoy  😉

pre-pend log timestamp

Adds a timestamp before alog from a script awk -v sec=$(date -u +%s) '{print strftime("%Y-%m-%d %H:%M:%S",sec), $0; fflush();}' in cron : awk -v sec=$(date -u +\%s) '{print strftime("\%Y-\%m-\%d \%H:\%M:\%S",sec), $0; fflush();}' So : # echo hello world | awk -v sec=$(date -u +%s) '{print strftime("%Y-%m-%d %H:%M:%S",sec), $0; fflush();}'   2014-10-30 08:40:26 test nJoy 🙂

VBS script to gather all IIS 6 Sites , state and folders for storage

This is a script from this site which I found particularly handy. OPTION EXPLICIT DIM CRLF, TAB DIM strServer DIM objWebService TAB = CHR( 9 ) CRLF = CHR( 13 ) & CHR( 10 ) IF WScript.Arguments.Length = 1 THEN strServer = WScript.Arguments( 0 ) ELSE strServer = "localhost" END IF WScript.Echo "Enumerating websites on…