天天看點

rc.local裡指定使用者來運作程式

需求描述:自己寫的一個阿裡雲的挂載OSS的腳本,需要指定非root賬号執行;

作業系統:CentOS release 6.8 

# vi /etc/rc.d/rc.local

#!/bin/sh

#

# 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/su - urs -c "/home/script/mount-oss.sh"

系統重新開機後:檢視程序;

#ps -ef|grep urs

]# ps -ef|grep urs

root       731   668  0 10:59 pts/5    00:00:00 su urs

urs        732   731  0 10:59 pts/5    00:00:00 bash

urs       1322     1  0 11:11 ?        00:00:00 ossfs cuishou-record /home/cuishou-record -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com

繼續閱讀