For example, to create a new script “vncserver”
sudo editor /etc/init.d/vncserver
Then enter the shell script.
Afterwards, make sure that you make the script executable after creation.
sudo chmod +x /etc/init.d/vncserver
Now insert the service into the start-up system so that it runs at boot
sudo insserv vncserver
Now, test to see if it works
sudo service vncserver start
To stop it
sudo service vncserver stop