how to start up a process on bootup

Asked by rhackenb

I am trying to start up a process on bootup. Let's assume there is a Perl script called ~/bin/test.pl. I would like to have that script start running when the machine boots up. My intention is for the script to run forever (until I either kill it or I shut down the machine).

I think I have to put something in /etc/rcX.d but what I actually have to do is somewhat murky. Can someone give me a brief description of what I have to do? Also, does it have to go into the /etc directory? I have root privileges to put it there but is there an alternative where I could put it in my home directory?

Thanks.

--rhackenb

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
rhackenb
Solved:
Last query:
Last reply:
Revision history for this message
Mario César Señoranis (mariocesar) said :
#1

If you don't have specials needs about the order of the start you can simple do.

$sudo vim /etc/init.d/yourscript

And paste all the code you want, then

$sudo update-rc yourscript defaults

This would create all the symbolic links on /etc/rc.*, so there are ready to boot on the start.

Don't forget to give the right permissions to your script, by doing

$sudo chmod +x /etc/init.d/yourscript

Regards from Bolivia.

Revision history for this message
Mario César Señoranis (mariocesar) said :
#2

This of course you have to do it inside the /etc/init.d/ folder :D

$sudo update-rc yourscript defaults
=
$sudo update-rc /etc/init.d/yourscript defaults

Don't forget to do a $man update-rc to look what you can do.

Revision history for this message
rhackenb (rgh3) said :
#3

Mario, thanks for answering.

There's still one thing that I'm not clear on. Do I put the actual script in /ect/init.d or should I put a link there to the actual script in my bin directory?

Also, what do you mean by 'defaults' in '$sudo update-rc /etc/init.d/yourscript defaults'? I don't think you actually mean the word 'defaults'. Maybe you mean any arguments that I may pass to the script. Is that it?

I will do a man on update-rc.

Thanks again.

--rhackenb

Revision history for this message
rhackenb (rgh3) said :
#4

Mario,

I read the man page and yes, I do use 'defaults' literally.

Bolivia! I was just in Peru and Ecuador and next spring we go to Chile. We'll have to schedule a trip to Bolivia in the future.

--rhackenb

Revision history for this message
Mario César Señoranis (mariocesar) said :
#5

> There's still one thing that I'm not clear on. Do I put the actual
> script in /ect/init.d or should I put a link there to the actual script
> in my bin directory?

Actually you can do it both ways, or making a link to a script on your
/usr/bin directory or create the script on the /etc/init.d/ directory

> Also, what do you mean by 'defaults' in '$sudo update-rc
> /etc/init.d/yourscript defaults'? I don't think you actually mean the
> word 'defaults'. Maybe you mean any arguments that I may pass to the
> script. Is that it?

I mean default, literally :)

> I will do a man on update-rc.
>
> Thanks again.
>
> --rhackenb

--
Mario César Señoranis Ayala.

Revision history for this message
Mario César Señoranis (mariocesar) said :
#6

> I read the man page and yes, I do use 'defaults' literally.
>
> Bolivia! I was just in Peru and Ecuador and next spring we go to Chile.
> We'll have to schedule a trip to Bolivia in the future.

Let me know when you came :D

Regards from Bolivia.