How to make a program start up at boot in OpenSuSE 13.2

I the old days I would go into /etc/init.d/ and add files where appropriate. Looking it now it seems like things have changed. Could some tell me the latest/best way to do this?

Although it probably doesn’t matter for this question I’m working in KDE.

Look for information/documentation about systemd.

Will do, thanks for the tip!

Hi,

/etc/init.d/ directory still has it’s use. You can check out that directory and you can see some init scripts are in there. However like what Henk said you can checkout systemd.

man systemd
man 5  systemd.unit
man 5 systemd.service

For local sysadmin the directory

/etc/systemd/system

is the recommended place for a unit file but the directory

/usr/lib/systemd/system

is also an option, which is where the packages (rpm) unit files should go.

Basically it is like an *.ini file or a *.desktop file. In KDE there is an auto start options for programs when you log-in.

Good luck. :wink:

If you want to start a system service check out YaST>Services manager. If you want to start a desktop service, System settings>Startup & shutdown>Autostart.

On Mon, 18 May 2015 18:26:01 +0000, Reg gie wrote:

> I the old days I would go into /etc/init.d/ and add files where
> appropriate. Looking it now it seems like things have changed. Could
> some tell me the latest/best way to do this?
>
> Although it probably doesn’t matter for this question I’m working in
> KDE.

The system now uses systemd for starting daemons, but it is backwards-
compatible to the old way of doing things, so you can create a script in /
etc/init.d as you used to, or you can learn the new way of doing things.

A google search turned up this example:

https://unix.stackexchange.com/questions/47695/how-to-write-startup-
script-for-systemd

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2015-05-18 20:26, Reg gie wrote:
>
> I the old days I would go into /etc/init.d/ and add files where
> appropriate. Looking it now it seems like things have changed. Could
> some tell me the latest/best way to do this?

As Jim said, you can still use old style scripts, or new style service
files. Also, for simple things you can just add lines to the
“/etc/init.d/*local” files.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

I cannot find either “System settings” or “Startup & shutdown”, where do I find these?

I’m using KDE4.

Type “systemsettings” into a terminal window or the Alt+F2 dialog.

If you use openSUSE in english, it’s called “Configure Desktop” in the K-menu. It has been renamed by openSUSE becase YaST is the “System settings” actually, systemsettings only is for user settings.

Actually, the default system Unit files are located in
/usr/lib/systemd/system

The files in the above location should never be touched, and you should be careful (almost never) add files to or modify files in the above location for a number of reasons.

Instead, if you ever want to create or modify existing Unit files, you should place those in the following locations

/etc/systemd/system/
or
/etc/systemd/user/

I recommend using the above locations differently than how jetchisel advised.

You should place files only in /etc/systemd/* which will over-ride files in /usr/lib/systemd/* where the default files exist.
Some benefits to keeping your custom modified Unit files separate

  • You can always return to the original simply by deleting your own (the original default is always preserved)
  • You can easily identify what is custom vs the system defaults.

As for the OP question,

  • For the forseeable future you can continue to create init style startup scripts but be aware that this legacy method is being obsolesced. For example, with 13.2 the cron job has been removed/severely modified so old scripts relying on cron either won’t work or won’t soon. So, it may be worthwhile to write your startup scripts “The systemd way”
  • Writing startup scripts for systemd isn’t that difficult.
    Find a Unit file in /usr/lib/systemd/* that looks close to what your app does to use as a template, copy and rename it to create your own in /etc/systemd/user/
    You’ll likely want to modify the Unit file’s “exec” command plus any desirable flags to point to your own script or binary to make this Unit file your own.
    Configure your Unit file to be invoked by multi-user.target (when openSUSE text initially boots) or graphical.target (just before the Desktop loads). There are various options depending on how hard a requirement you want your app to be (if an error, a show stopper? simply a warning?)

Note that no matter what you use as a template, I don’t recommend placing it in /etc/systemd/system, although the file location does not matter I use that location only for modified system Unit files. I place all Unit files relating to non-core apps including anything I might want to invoke in /etc/systemd/user/ instead.

HTH,
TSU

Just wanted to say thanks! I believe I have a clear picture now.