I'd like to run a script at startup without actually adding it as a command to rc.local, just by copying a script somewhere.

I know in theory I can put it into /etc/init.d but that's really for services, not scripts that are just supposed to run on startup.

I know about the cron @reboot option as well but I really would prefer something where I just copy a script over to a directory and then can forget about it.

Basically, in the same way you can just put a file in /etc/cron.daily or /etc/logrotate.d I'm wondering if there's an equivalent folder where you just put in a file and it runs at startup.

If necessary I'm willing to install a program that does this for you, so long as it's stable.


I've managed this with the following which works well.

Create /etc/cron.d/reboot with the contents below. Note - It's been a while, you should check syntax.

@reboot root run-parts  /etc/cron.reboot

Create a folder /etc/cron.reboot

From there it's a matter of dropping files in to the cron.reboot folder.

  • This sounds perfect, even down to ending up with a directory structure that reflects my purpose. – Jordan Reiter Jan 21 '16 at 15:53
  • Just one important change: @reboot run-parts /etc/cron.reboot should be @reboot root run-parts /etc/cron.reboot. The cron file has to have the user indicated. – Jordan Reiter Jan 21 '16 at 18:37
  • @JordanReiter as an alternative you can add this the run-parts command to the rc.local just once. – Tim Brigham Jan 21 '16 at 21:57
  • Yeah, part of why I like your solution is it lets me keep rc.local untouched. This is a setup for a auto-launched instance so it's much nicer to be able to have the install script just copy the files over to a folder rather than modify existing files in rc.local. This way I can even commit these cron files to source control. – Jordan Reiter Feb 1 '16 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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