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

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

$su -c 'command' - user

$sudo -u jetty ./nexus start

实例


/etc/rc.localexit 0之前加入如下内容:

#vim /etc/rc.local
su - jetty -c "/data/nexus/nexus-2.12.0-01/bin/nexus start"

参考链接


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

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注