19

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.

4
  • Running an application (aka service) at boot is nicely elaborated here: askubuntu.com/questions/19320/how-to-enable-or-disable-services - Note that running a daemon on booting is different from running an application at login.
    – Takkat
    Aug 6, 2015 at 8:15
  • this post has nothing specific to daemons at boot, this applies to anything, the comannd could be sudo chmod 777 /home/user/sharedfiles/ -R the point is that it is broad, run ANY script or command after boot Aug 6, 2015 at 10:48
  • the issue that started this is unrelated to the question, the command I wanted to run at boot.. sudo service deluged restart, it was just an example Aug 6, 2015 at 10:49
  • The link how to run scripts at startup has the answer I was looking for but it is a different question. My question is that I only needed to run a single command. But thanks for linking to a proper answer! There are multiple good options in that post Aug 8, 2015 at 2:38

1 Answer 1

23

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!

3
  • 1
    Doesn't work in version 20.
    – misantroop
    May 4 at 4:09
  • 1
    This answer does: askubuntu.com/a/816/475744
    – EpicVoyage
    Jul 19 at 16:27
  • 1
    @EpicVoyage that is certainly an option, but I had issues w/ @reboot in cron where the service started to early and failed to start correctly. Still, if it works, I'd say that's possibly the best most universal approach. Jul 19 at 17:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.