Show all cronjobs for all users

This is a simple script to get all cronjbs for all users on a system

for someone in $(cut -f1 -d: /etc/passwd); do echo $someone; crontab -u $someone -l ; done

nJoy 😉

 

incrond cannot exec process: No such file or directory

Inside your 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 /var/log/syslog there were these messages

incrond[27693]: cannot exec process: No such file or directory

This was because of having 2 spaces… when I corrected to only 1 space, it began working correctly. Keep it in mind, so you dont suffer as much as I did to find it out 🙂

After editing with “incrontab -e”, check that “incrontab -l” shows the rules. If it does not show some rule, then that is because that rule has some error and was not recognized.

To debug what is happening behind the curtains, its usefull to have a “tail -f /var/log/syslog” on another terminal…

Quoted from https://zipizap.wordpress.com/2013/11/15/incron/

Very useful thanks !

😉 nJoy

Dummy node script to respond 200 (or anything) to a call for testing purposes

This is as bare a node App as you can make but it comes in handy when you want a . dummy server just to return 200s and or a JSON object at super fast speeds on small systems:

 

var express = require('express');

var app     = express();


app.get('*', function(req, res) {
    res.sendStatus(200);
});

app.listen('3000');

console.log('Magic happens on port 3000');

exports = module.exports = app;


Before running the js file run 
npm install express 

to deploy express..

Thats it !

nJoy 😉

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 :

 

 

 

 

 

 

 

 

 

It can Also be used in scripts as :

sysv-rc-conf atd <on or off> and --levels;

man sysv-rc-conf

Will give you some love..

nJoy 😉

 

 

Reboot required Ubuntu

To find out what triggered this use :

more /var/run/reboot-required.pkgs

nJoy 😉

converting webm to mp3s ffmpeg

for FILE in *.webm; do
    echo -e "Processing file '\e[32m$FILE\e[0m'";
    ffmpeg -i "${FILE}" -vn -ab 128k -ar 44100 -y "${FILE%.webm}.mp3";
done;

nJoy 😉

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 [ "${SOURCEFOLDER:SF_LEN}" != "/" ] ; then
   echo "Adding trailing slash"
  SOURCEFOLDER=$SOURCEFOLDER"/"
fi



#echo "Last character in target folder is ${TARGETFOLDER:TF_LEN}"
if [ "${TARGETFOLDER:TF_LEN}" != "/" ] ; then
   echo "Adding trailing slash"
  TARGETFOLDER=$TARGETFOLDER"/"
fi



echo $SOURCEFOLDER
echo $TARGETFOLDER

LOCKFILE=/tmp/`echo $0 $SOURCEFOLDER $TARGETFOLDER | sed "s/[^[:alnum:]]/_/g"`.lck
echo "Lockfile : $LOCKFILE"



[ ! -d $SOURCEFOLDER ] && echo "Source does not exist !! $SOURCEFOLDER exitting with error" && exit 1;

TIMESTAMP=$(date --utc +%Y%m%d%H%M )
#echo $TIMESTAMP



if [ ! -d $TARGETFOLDER ]; then 

mkdir $TARGETFOLDER

rsync -av --delete  $SOURCEFOLDER $TARGETFOLDER/$TIMESTAMP/

else 

[ -d $TARGETFOLDER/$TIMESTAMP/ ] && echo "Folder already there !! Leaving.. " && exit 0;  

 LASTBACKUP=$(ls $TARGETFOLDER | sort -rn | head -1)
 echo "Link copying $TARGETFOLDER/$LASTBACKUP to $TARGETFOLDER/$TIMESTAMP/"
 cp -al $TARGETFOLDER/$LASTBACKUP $TARGETFOLDER/$TIMESTAMP/
 rsync -av $SOURCEFOLDER $TARGETFOLDER/$TIMESTAMP/

fi

echo " OK !! Done"

 

 

 

Simple page to redirect to https from index.html

<html>
<head>
<title>
Redirecting...</title></head>
<script language="JavaScript">
function redirectHttpToHttps()
{
    var httpURL= window.location.hostname + window.location.pathname + window.location.search;
    var httpsURL= "https://" + httpURL;
    window.location = httpsURL;
}
redirectHttpToHttps();
</script>
<body>
</body>
</html>

 

nJoy 😉