문제

I am trying to have my Ubuntu 12.04 LTS server run a bash script I have to start a Minecraft server on start up, prior to log in but as user minecraft. I can have it run as root by placing the following in /etc/rc.local

bash /path/to/script/script.sh

which runs the script as root, I have tried the following in /etc/rc.local

su -c `bash /path/to/script/script.sh` minecraft

but to no avail. Can anyone tell me what I am doing wrong or should be doing instead? The first line of my script is

#!/bin/bash

in case it is important. Thanks much!

도움이 되었습니까?

해결책

Try

su minecraft -c '/bin/bash /path/to/script/script.sh &'
  • The user should be the first argument to su.
  • You should use quotes and not ticks for the command argument (-c)
  • You may want to consider using su -l minecraft to have the script run in an environment which would be similar to that if the user minecraft logged in directly.

Give this a shot and let me know if it works.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top