Startup Scripts

Hi,

I am trying to run some simple startup shell scripts when the system boots. It used to be an easy task by putting the script in /etc/init.d. But now with systemd I have no idea how this can be done. I’ve tried to put them in etc/rc.local, etc/init.d, but the scripts don’t seem to run. I’ve seen some tutorials to put the scripts in a service with systemctl, which I haven’t yet tried. But there must be some other ways?

Kernel version:
Linux beaglebone 4.4.34-ti-r69 #1 SMP Wed Nov 23 20:01:14 UTC 2016 armv7l GNU/Linux

Thanks for the help!

Best Regards,

Ricky Chang

I am trying to run some simple startup shell scripts when the system boots.

One thing I tend to use is the @reboot keyword in cron. For example:

cat /etc/cron.d/startup_scripts
MAILTO=“”
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

@reboot root /home/stephane/scripts/check_for_upgrade.sh
@reboot root /home/stephane/scripts/startup_commands.sh

Stéphane

Hi Stephane,

Yes crontab will work. I’ve also found that rc.local did run only for some reasons it couldn’t execute my scripts, I’d look into that further. Thanks for the help!

Hi,
If you're after a simple 'single shot' startup, you can use this as a template. I wrote this one because the flashing LEDs seemed to ... distract ... the pets at night...

https://github.com/PeteLawler/starnix-recipes/blob/master/etc/systemd/system/bb-leds-off.service

Instructions on how to install it are in the comments.

I believe there are ways to have your old style SysV init scripts work with systemd, but I'd suggest for future proofing sake you may be better off just going with the flow.

Cheers,

Pete.

Hi Peter,

Thanks for the template!