Saturday, December 24, 2016

boot - Automatically Run a Command/script at startup




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.



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



and I tried adding both



# By default this script does nothing.

/home/donut/deluge.sh
(or)
sudo service deluged restart

exit 0



the first, i created a script in /home/donut/deluge.sh



with JUST



sudo service deluged restart


the second I just pasted the command right into rc.local




The second works fine for me, but if you have a long script, or a script you want to change a lot without editing rc.local, then the first option is for you.



Cheers!


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...