Automatically Run a Command/script at startup [duplicate]

This question is ALL over ubuntu, with MODS saying its duplicate, but I have found no good answers!

I want to run the command, (this will work for script as well)

sudo service deluged restart

at boot after everything is done, IE: last thing to run

I first found this post, marked duplicate

Auto Run a command at startup

Which seth blocked from future help and linked to this post

Start Applications at startup

First off, I run a server, not a desktop (Which is what the linked "duplicate" guide shows you), so I can only use CLI based guides. Second those are 2 different questions.

Then there is this post

Run a command at startup

Marked as duplicate and linked to this question which may answer his specific question, but does not answer the question, run a command at boot.

Why isn't my upstart service starting on system boot?

Anyway, there is more!, but what I am getting at is I know what I want is just ONE example of how to do this via CLI and simple. I am not a coder, but I can read code and edit it to suit my needs and understand it, i just can't create it so to speak.

As another mod (takkat) has said, this is a duplicate of a question relating to

how to enable to disable services but again my point is that this post, i am using

sudo service deluged restart

as an example on how to run a command/script at boot, not troubleshooting why a service is not runnnig. While rc.local may serve as a dirty fix for a problem i have, deluge web-ui auto connect it can be used in a lot of other situations.

please try to answer the question directly, not give me links to what you think might help, and if it is a duplicate then link to a cli guide that covers HOW TO RUN A COMMAND/SCRIPT AT BOOT, because CLI guides can be used by both desktop and server users of Ubuntu.


Solution 1:

rc.local has solved this for me, and although I have read is outdated But kept around for compatibility, if somebody has the updated, but JUST AS SIMPLE answer, please share as I will update my server.

sudo nano /etc/rc.local

You can use either calling a script in rc.local or directly run desired commands. Eg:

# By default this script does nothing.

/root/script.sh
(or)
sudo service deluged restart

exit 0

Cheers!