set_core.sh 944 字节
Newer Older
H
Hui Li 已提交
1 2 3 4
#!/bin/bash
#
# This file is used to set config for core when taosd crash

H
Hui Li 已提交
5 6 7 8 9 10 11
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

H
Hui Li 已提交
12
# set -e
H
Hui Li 已提交
13
# set -x
H
Hui Li 已提交
14
corePath=$1
H
Hui Li 已提交
15 16 17 18 19 20

csudo=""
if command -v sudo > /dev/null; then
  csudo="sudo"
fi

H
Hui Li 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33
if [[ ! -n ${corePath} ]]; then
  echo -e -n "${GREEN}Please enter a file directory to save the coredump file${NC}:"
	read corePath
  while true; do
    if [[ ! -z "$corePath" ]]; then
      break
    else
      read -p "Please enter a file directory to save the coredump file:" corePath
    fi
  done
fi

ulimit -c unlimited
H
Hui Li 已提交
34 35
${csudo} sed -i '/ulimit -c unlimited/d' /etc/profile ||:
${csudo} sed -i '$a\ulimit -c unlimited' /etc/profile ||:
H
Hui Li 已提交
36 37
source /etc/profile

H
Hui Li 已提交
38 39 40
${csudo} mkdir -p ${corePath}  ||:
${csudo} sysctl -w kernel.core_pattern=${corePath}/core-%e-%p  ||:
${csudo} echo "${corePath}/core-%e-%p" | ${csudo} tee /proc/sys/kernel/core_pattern  ||: