Linux 以普通用户自启动服务

Posted by wxianfeng Fri, 26 Oct 2012 18:52:00 GMT

linux 自启动服务 默认是以root启动的, 但是我们很多服务都是以普通用户启动的, 如果以root启动 , 这样会到来一些权限问题,例如应用中保存的文件等等.


su - user -f /path/shell



[wxianfeng@li390-146 ~]$ cat /etc/rc.local
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/bin/sh /usr/local/system/www/shell/linode/ >> /usr/local/system/logs/init.log 2>&1
su - wxianfeng -f /usr/local/system/www/shell/linode/ >> /usr/local/system/logs/init.log 2>&1 脚本


# nginx

# mysql
/etc/init.d/mysqld start

# svn
svnserve -d -r /usr/local/system/vcs 脚本


source /usr/local/rvm/environments/ruby-1.9.2-p180

cd /usr/local/system/www/project_manager

thin start -e production -d -p 5000

source /usr/local/rvm/environments/ruby-1.8.7-p334 

thin start -C /etc/thin/thin.yml

This entry was posted on Fri, 26 Oct 2012 18:52:00 GMT and Posted in , . You can follow any any response to this entry through the Atom feed. You can leave a comment or a trackback from your own site.

Tags ,


Use the following link to trackback from your own site:


Leave a comment