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

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

 

实例

在/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"

 

相关文章:

  • 2021-12-03
  • 2021-08-04
  • 2022-12-23
  • 2022-02-08
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-29
  • 2022-02-09
  • 2022-12-23
  • 2021-12-15
  • 2021-11-19
  • 2021-11-28
  • 2021-11-28
相关资源
相似解决方案