0

Each time I startup the sistem I need to run this command sudo xhost + and the sudo service myservice restart

I have decided to add a script to startup to avoid having to type it each time myself.

I followed the instructions from here How to run a script during boot as root

I created myscript.sh in /etc/init.d and then ran chmod 755 on it then I created a simlink in /etc/rc2.d/S99myscript.sh

here is the content of my script:

#!/bin/bash

sudo xhost +
sudo service siemcy restart

ls -l /etc/init.d/my_custom_startup_script.sh

-rwxr-xr-x 1 root root 54 Apr 9 10:10 /etc/init.d/my_custom_startup_script.sh

But when I reboot seems the sript is not run, service siemcy is not running because it needs xhost + so basiclly the screept is not run. Or the script is not run at the right time. Any advice? did I put the script in the wrong place? thanks

1 Answer 1

0

Maybe service siemcy is not yet started, so you should first start it, and then restart it.

Alternatively, you could copy your code in /etc/rc.local before the exit 0 tag.

Hope it helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .