How can I start program on boot in Ubuntu 14.04?
Solution 1
There are more than one way to accomplish this.
You can put your startup script in
/etc/init.d
and make it resemble to one of the existing scripts over there. But depending on your Linux comfort level, this may be a little daunting.You can make this a service and make the service start at the boot time. Just do a google search on "how to make my program a service" and you will come across a lot of pages. More than what you can shake a stick at.
If your app is startin g with one single command and is not dependent on anything else, you can add the start-up command at the end of
/etc/rc.local
file.
You can also put it in the cron to execute at the startup but this is not the way it should be done, in my opinion
Solution 2
Ubuntu normally has Vixie cron installed. You can use @reboot for a normal user's crontab
file. From the man page:
Instead of the first five fields, one of eight special strings may
appear:
string meaning
------ -------
@reboot Run once, at startup.
....
Related videos on Youtube
Daniel T
Updated on September 18, 2022Comments
-
Daniel T over 1 year
Is the root crontab the only way? I'm starting up a MC server and don't want it to need me to manually restart it each time the server reboots for whatever reason. I don't want any login required for these programs to initialise.
I'm using
ssh
to get into this server, it's a VPS, nothing local. -
Daniel T about 8 yearsThe advice I was given was to add this to the crontab... @reboot cd ~/McMyAdmin && screen -dmS McMyAdmin ./MCMA2_Linux_x86_64 ...but sadly it didn't work. :(
-
Daniel T about 8 yearsThanks! The original advice I was given from a web page was to run the following... @reboot cd ~/McMyAdmin && screen -dmS McMyAdmin ./MCMA2_Linux_x86_64 ...sadly it didn't work using my non-root account.
-
Anthon about 8 yearsYou should at least expand the paths (not use
~
). Or better make a script in which you do everything, assuming your PATH is only/usr/bin:/bin
and then call that script from the crontab.