= bash = Bourne again shell. == Server loop == {{{#!highlight bash #!/bin/sh # restart the server in case of failure logger "Starting server.py" until /usr/bin/python server.py 1234; do logger "Server crashed with exit code $?. Respawning.." sleep 1 done }}} == Add extra IP address to NIC == Adapted from http://unclean.org/howto/secondip.html Add extra IP 192.168.1.5 to NIC eth0 {{{#!highlight bash ifconfig eth0:0 192.168.1.5 route add -host 192.168.1.5 dev eth0:0 }}} == Check port running == {{{#!highlight bash #!/bin/sh RES=`netstat -at -n | grep 0.0.0.0:12345 | wc -l` if [ $RES -eq '1' ] then logger 'Process running' else logger 'Process not listening on port 12345' /sbin/service processx restart logger 'Process restarted' fi }}} {{{#!highlight bash #!/bin/sh RES=`netstat -at -n | grep 0.0.0.0:12345 | wc -l` if [ $RES -ne '1' ] then logger 'Process not listening on port 12345' /sbin/service processx restart logger 'Process restarted' fi }}} == ColorBash prompt == https://wiki.archlinux.org/index.php/Color_Bash_Prompt * start coloring: \[\e[color\] * end coloring: \[\e[m\] * \e[0;32m\] #green color * \e[0;33m\] #yellow color == Network interface data daily == rxtxData.sh: {{{#!highlight bash #!/bin/sh # chmod 755 rxtxData.sh # crontab -e # @daily /root/rxtxData.sh CURR=`date -u` DATA=`ifconfig eth0 | grep "RX bytes" | sed "s/:/ /g"` echo [$CURR] $DATA >> /root/rxtxData.log }}} == SSH Ubuntu bash colors == '''~/.bash_profile''' {{{ if [ -f ~/.bashrc ]; then . ~/.bashrc fi }}} '''~/.bashrc''' {{{ alias ls='ls --color' alias ps='ps faxo pid,user:32,comm' #PS1="\e[0;33m\]\D{%Y-%m-%d}T\A\[\e[m\] \e[0;32m\]\u@\H:\w\r\n\$\[\e[m\] " export PS1="\e[0;33m\]\D{%Y-%m-%d}T\A\[\e[m\] \e[0;32m\]\u@\H:\w\r\n\$\[\e[m\] " PATH=$PATH:/opt/java/jdk1.8.0_162/bin:/opt/java/apache-maven-3.5.3/bin }}}