TransWikia.com

OpenSuse Tumbleweed: How to run a bash script on startup?

Unix & Linux Asked on December 11, 2020

I’m trying to a run a .sh file on startup of a rPi3B+ running openSuse Tumbleweed JeOS. The script is really simple and looks like this:

node /home/user_name/path/to/the/file.js

here are two links I tried to follow:

https://forums.opensuse.org/showthread.php/428743-How-to-run-script-at-startup
https://www.suse.com/c/easy-running-scripts-boot-and-shutdown/
https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/cha.adm.shell.html

How how to go about this?

Edit: I also just tried following along to this one without any luck either: https://stackoverflow.com/questions/12973777/how-to-run-a-shell-script-at-startup#12973826

My startServer script in /etc/init.d looks like this:

#!/bin/sh
# ScriptName=startServer
node /home/user-name/server.js &

One Answer

/etc/init.d/after.local

create this file and from within call your script.sh it will execute as root.

Otherwise you can call it via su -c '/path/yourscript.sh' username where username is whatever valid user account.

After the system is fully booted if /etc/init.d/after.local exists then whatever is in it will be run. You can chmod 600 /etc/init.d/after.local and chown root.root /etc/init.d/after.local if you are concerned about security.

your StartServer script in /etc/init.d looks like this:

/etc/init.d/StartServer.sh

it contains

#!/bin/sh
# ScriptName=startServer
node /home/user-name/server.js &

create /etc/init.d/after.local and its contents is simply

/etc/init.d/StartServer.sh
  1. after system is fully booted, the last step [this is a suse thing] it will try to execute the file /etc/init.d/after.local if it exists
  2. you manually create /etc/init.d/after.local and put /etc/init.d/StartServer.sh in it
  3. your StartServer.sh script gets run after the system is fully booted.

Answered by ron on December 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP