设置开机自启动

sh/bash/dash/ksh/zsh等Shell脚本
回复
罗非鱼
帖子: 980
注册时间: 2008-04-12 12:44

设置开机自启动

#1

帖子 罗非鱼 » 2011-08-12 9:04

问题提出:每次开机后,我使用
ps aux 得到下面的输出(删除部分,保留我关心的部分),现在我想关闭tinyproxy,postgres的开机自启动.

nobody 3059 0.0 0.2 4088 2732 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3062 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3063 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3064 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3065 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3066 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3067 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3068 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3069 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3070 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
nobody 3071 0.0 0.2 4088 2416 ? S 08:07 0:00 /usr/sbin/tinyproxy
postgres 1372 0.0 0.5 46788 5188 ? S 08:07 0:00 /usr/lib/postgresql/8.4/bin/postgres -D /var/lib/postgresql/8.4/main -
postgres 1791 0.0 0.1 46788 1220 ? Ss 08:07 0:00 postgres: writer process
postgres 1792 0.0 0.0 46788 964 ? Ss 08:07 0:00 postgres: wal writer process
postgres 1793 0.0 0.1 46924 1368 ? Ss 08:07 0:00 postgres: autovacuum launcher process
postgres 1794 0.0 0.1 14956 1088 ? Ss 08:07 0:00 postgres: stats collector process
所有输出如下,全部删除注释
1.sudo gedit /etc/rc.local

ifconfig eth0 up
pon dsl-provider
hald deamon=no
exit 0

2.sudo gedit ~/.bashrc

[ -z "$PS1" ] && return
HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi

3.sudo gedit /etc/init.d/rc.local

PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start() {
if [ -x /etc/rc.local ]; then
[ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
ES=$?
[ "$VERBOSE" != no ] && log_end_msg $ES
return $ES
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac

上面三个文件是网上讨论开机自启动常常谈到的三个文件,都没有设置tinyproxy,postgres,我如何关闭他们的开机自启动??
gzbao9999
帖子: 627
注册时间: 2008-11-08 18:34

Re: 设置开机自启动

#2

帖子 gzbao9999 » 2011-08-12 12:01

不同runlevel对应各自的启动文件目录 rc*.d/
找到对应的S字头的启动文件,把S换成K就好了
气血鼓荡,身体发胀,偶飘上头,三时舒畅
回复