2014年12月31日 星期三

[FW]linux - bash script environment variables

Reference:https://sites.google.com/site/tiger2000/home

$BASH_ENV absolute path of startup file
$CDPATH directories searched by cd
$FCEDIT absolute path of history editor
$HISTCMD the history number of the current command
$HISFILE absolute path of history file
$HISTSIZE number of remembered commands
$HOME login directory
$IFS token delimiters
$LINENO current line number in shell script
$LINES terminal height
$MAIL  absolute path of mailbox
$MAILCHECK number of seconds to check mail
$OLDPWD absolute path of previous directory
$OPTARG option set by getopt
$OPTIND option's ordinal position set by getopt
$OSTYPE the OS on which bash is executing
$PATH command search path
$PPID  process ID of parent
$PS1  primary prompt
$PS2 secondary prompt
$PWD absolute path of current directory
$RANDOM random integer
$REPLY default variable for read
$SECONDS number of seconds since shell started
$SHELL absolute pathname of preferred shell
$TMOUT seconds to log out after lack of use
$UID user ID of the current user
$$ process ID of current shell
$? exit status of most recent statement
$# 參數的數目
$* 代表所有參數
$! PID of the most recently started backgroup job

2014年12月30日 星期二

[FW] Linux - shell script - detect multiple running instances of it self


Reference: http://giantdorks.org/alain/make-a-bash-script-quit-if-it-detects-multiple-running-instances-of-itself/

#!/bin/bash
if [ "$(pgrep -x $(basename $0))" != "$$" ]; then
 echo "Error: another instance of $(basename $0) is already running"
 exit 1
fi

Redmie - Useful plugin



  1. redmine dashboard
    1. Info: http://www.redmine.org/plugins/redmine-dashboard
    2. Steps
      1. cd /opt/bitnami/apps/redmine/htdocs/plugins
      2. git clone https://github.com/jgraichen/redmine_dashboard.git
      3. bundle install
  2. redmine default assign
    1. Info: https://github.com/giddie/redmine_default_assign
    2. Steps
      1. cd /opt/bitnami/apps/redmine/htdocs/plugins
      2. git clone https://github.com/giddie/redmine_default_assign.git
      3. rake db:migrate_plugins RAILS_ENV=production