nohup example

here’s a nohup example:

nohup nice -n -19 /bin/bash cidr_to_ipset.sh all_countries.txt 2>&1 >/root/cidr_to_ipset_output.log </dev/null &

nohup is a POSIX command to ignore the HUP (hangup) signal. The HUP signal is, by convention, the way a terminal warns dependent processes of logout.

Output that would normally go to the terminal goes to a file called nohup.out . . . → Read More: nohup example

Apache ProxyPass with dynamic hostname

To use Apache ProxyPass directives with dynamic hostnames you will need to also use ModRewrite.

Objective

All requests to the virtualhost will ProxyPass and ProxyPassReverse (also known as an “Apache Gateway”) to the %{HTTP_HOST}

The only reason this would make sense to do is if you have localhost entries on the apache server for specfic . . . → Read More: Apache ProxyPass with dynamic hostname

curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

Problem

When running curl you get this response:

curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) Solution curl -ssl3

shred files on Centos

Here’s a handy alias for shredding files on CentOS

alias shred=’shred -v -n 1 -z -u’

chkconfig with color on centos

alias chkconfig=”chkconfig | perl -pe ‘use Term::ANSIColor; s/\bon\b/color(\”green\”).on.color(\”reset\”)/ige;’”

or to permit passing an agrument:

function chkconfig(){ /sbin/chkconfig $* | perl -pe ‘use Term::ANSIColor; s/\bon\b/color(“green”).on.color(“reset”)/ige;’ }

nano syntax highlighting

nano syntax highlighting

This article describes how to get syntax highlighting in the command line emacs editor “nano“

Ubuntu zcat /usr/share/doc/nano/examples/nanorc.sample.gz > ~/.nanorc sed -i ‘s|# include|include|g’ ~/.nanorc Centos/Redhat cp /usr/share/doc/nano-2.0.9/nanorc.sample ~/.nanorc sed -i ‘s|# include|include|g’ ~/.nanorc

my bash prompt

Installation

Modify ~/.bashrc and append this line

PS1=”\n\[\e[32;1m\][\[\e[37;1m\]\u@\h:\[\e[37;1m\]\w\[\e[32;1m\]]\\$ \[\e[0m\]” My Bash Prompt

Setup Email on Centos

To setup email on Centos 6 run these commands yum -y install sendmail mailutils chkconfig –levels 235 sendmail on service sendmail restart To send a test email echo “test message” | mail -s “test subject” [email protected] Hosts File

Modify your hosts file and add $HOSTNAME.local to prevent issues (in example below we are using hostname . . . → Read More: Setup Email on Centos

Add Current PATH to crontab

Add Current PATH to crontab

Are you sick of your cron job failing because you are not explicitly listing the full path of everything in your shell script? Here’s how to fix it!

Problem

Your script works when you run it from the console but fails in cron.

Cause

Your crontab doesn’t have the right . . . → Read More: Add Current PATH to crontab

self deleting bash script

How to create a bash script that deletes itself

This script will delete itself via the shred command (secure deletion) when it exits

#!/bin/bash # # Author: Steve Stonebraker # Date: August 20, 2013 # Name: shred_self.sh # Purpose: securely self-deleting shell script # http://brakertech.com/self-deleting-bash-script currentscript=$0 # function that is called when the script exits . . . → Read More: self deleting bash script