您的位置:首页 > 运维架构 > Shell

shell下root用户切换其他用户运行程序

2013-10-01 14:14 309 查看
工作中,一些程序,需要随机启动,但是不是以root用户运行,于是需要在rc.local中通过shell,从root用户切换到其他用户运行程序,命令如下:

su -c 'command' - user
sudo -u peter /home/blue/hi.sh


[b]实例[/b]

在/etc/rc.d/rc.local中加入如下内容:

#vi /etc/rc.d/rc.local
su - oracle -c "/u01/app/oracle/product/9.2.0.4/bin/lsnrctl start"
su - oracle -c "/u01/app/oracle/product/9.2.0.4/bin/dbstart start"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐