PDA

View Full Version : SLES 15 SLES 15 - How to run script at startup



phrix
15-Oct-2018, 20:06
Hello,

I am try with Suse Linux Enterprise 15 for upgrade my server, but I don't find where I run my script of inicialization, befor in SLES 12 I put in /etc/init.d/after.local but this file don't exist in this version.

Thanks in advanced.

malcolmlewis
15-Oct-2018, 21:17
Hello,

I am try with Suse Linux Enterprise 15 for upgrade my server, but I don't find where I run my script of inicialization, befor in SLES 12 I put in /etc/init.d/after.local but this file don't exist in this version.

Thanks in advanced.
Hi
You can create a simple systemd service file pointing at your script in /etc/systemd/system called say script001.service containing;


# /etc/systemd/system/script001.service
#

[Unit]
Description=Run my boot script

[Service]
Type=oneshot
ExecStart=/bin/sh -c "/path/to/script/scriptname"

[Install]
WantedBy=multi-user.target


Once that's saved, you can run, check and enable;


systemctl start script001.service
systemctl status script001.service
{if all ok}
systemctl enable script001.service

phrix
16-Oct-2018, 12:54
Perfect Malcolm!

Thanks.