Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 34717  / 3 Years ago, sat, june 26, 2021, 7:12:40

I'm trying to understand the init process.



I have a script which launches 3 background processes (2 shell scripts and a java app). It works just fine from the command line.



I'd like to execute that script at startup.



/etc/init.d/skeleton didn't make sense to me because it was looking for a single process it seemed. And most init scripts seems so complex I'm getting sort of lost.



All I really want to do is:



#!/bin/bash
/opt/myapp/bin/my_start_script


If that just happened at startup I'd be very happy.


More From » boot

 Answers
4

You can add your link to the Startup Applications application in Ubuntu if you want to use the GUI. The downside of this is that it will only execute when you log in to the GUI (i.e. not for other users, and not if you don't log in to the Ubuntu Desktop environment).



Using the command line, you can cause a script to run before the Ubuntu Desktop loads.



To do this, make your script executable, copy it to /etc/init.d and create a symbolic link to the script in /etc/rc2.d if you want it executed in the default multi-user runlevel (runlevel 2). You should rename it with an S followed by the order you want it executed in, respective to the other links in there.




  1. Make script executable:



    sudo chmod u+x myscript.sh


  2. Copy it to /etc/init.d:



    sudo cp myscript /etc/init.d


  3. Create a symlink in rc2.d:



    cd /etc/rc2.d



    sudo ln -s /etc/init.d/myscript.sh


  4. Rename it according to the naming scheme:



    sudo mv myscript.sh S70myscript.sh




For more information, see the README files in /etc/init.d and /etc/rc2.d.


[#42564] Sunday, June 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
giccolla

Total Points: 161
Total Questions: 124
Total Answers: 117

Location: Aland Islands
Member since Wed, Nov 17, 2021
3 Years ago
giccolla questions
Sun, Oct 17, 21, 05:39, 3 Years ago
Mon, Aug 1, 22, 02:00, 2 Years ago
Sun, Nov 21, 21, 08:21, 3 Years ago
;