Running scripts at startup (Ubuntu)
There is quite a bit of advice online about how to run scripts automatically at startup on Ubuntu. Most of them provide instructions about how to use rc.local
for this task. As I looked at this option, though, it seemed a little complicated for my tastes.
After doing some poking around, the method that appealed most to me, and seemed to be both safe and reliable, was to use a cron
job. The linked post spells out the rationale and steps, but for my own records, this is the process I used:
Compose the script. I typically keep mine in
/home/[user]/.local/bin/
which is on myPATH
. In my case, I wanted to keep a copy of an app profile at each startup, as rude things sometimes happened if it was updated: so I have anapp-copy-profile
script.Set up the
cron
job. There are different approaches advocated here, but since this is dead easy, I simply invoke$ crontab -e
, which opens for me in the nano editor. At the bottom of the file, I added the line:@reboot /home/[user]/.local/bin/app-copy-profile
Save, and done.
Now, at each startup (not only “reboot”), the script runs. This can be implemented for multiple scripts, of course.