power up script as user

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

power up script as user

730件の閲覧回数
davidvescovi
Contributor V

I was able to create a service that launches a script on power up. The script lives in the \home\root directory and this works to subsequently launch my application (./zzz.out). This does indeed work except if I want to display a window on my monitor. If I log in as root and launch the script it does show the window.

the script looks like:

#!/bin/bash
cd $(dirname $0)
./zzz.out

Is there a way to modify the script so it launches the app as the root user so I can see the window without actually manually logging in?

0 件の賞賛
返信
1 返信

688件の閲覧回数
b36401
NXP Employee
NXP Employee

You can add starting your application into /etc/rc.local file.

Alternativelly you can place your script into /etc/init.d

root@imx8qmmek:/etc/init.d# cat test.sh
#!/bin/sh
echo test > /file.txt
root@imx8qmmek:/etc/init.d# ls -l test.sh
-rwxr-xr-x 1 root root 22 May 25 18:50 test.sh
root@imx8qmmek:/etc/init.d#

and add it into exact runlevel:

root@imx8qmmek:/etc/init.d# runlevel
N 3
root@imx8qmmek:/etc/init.d# cd /etc/rc3.d/
root@imx8qmmek:/etc/rc3.d# ln -s ../init.d/test.sh S50test.sh
root@imx8qmmek:/etc/rc3.d#

Is it what you are asking for?
Or you need the script to run as some user other than root?
In this case you can use "su" command in the script and point exact user.
I mean something like that:

# su the_user -c /path/to/the/command

0 件の賞賛
返信