https://unix.stackexchange.com/questions/43230/how-to-run-my-script-after-suse-finished-booting-up
https://kerneltalks.com/howto/execute-command-at-shutdown-and-boot-in-suse-linux/
To enable /etc/init.d/after-local, systemctl enable after-local.service To check status of /etc/init.d/after-local, systemctl status after-local.service
要先打开after-local ,不然不生效.
linux-oad7:/home # systemctl status after-local.service ● after-local.service - /etc/init.d/after.local Compatibility Loaded: loaded (/usr/lib/systemd/system/after-local.service; static; vendor preset: disabled) Active: active (exited) since Thu 2020-04-30 00:16:57 CST; 8h left Process: 1797 ExecStart=/etc/init.d/after.local (code=exited, status=0/SUCCESS) Main PID: 1797 (code=exited, status=0/SUCCESS) Tasks: 0 CGroup: /system.slice/after-local.service Apr 30 00:16:57 linux-oad7 systemd[1]: Started /etc/init.d/after.local Compatibility. Apr 30 00:16:57 linux-oad7 after.local[1797]: fdsafasdfasdf linux-oad7:/home #
是不否可用.
after.local配置,注意不是after-local ,
文件名是after.local ,服务名是after-local
linux-oad7:/home # cat /etc/init.d/after.local #!/bin/sh echo 'fdsafasdfasdf' /home/test1& linux-oad7:/home # cat /home/test1 #!/bin/sh echo nameserver aaa >/home/222.txt echo nameserver 114.114.115.115 >/etc/resolv.conf echo nameserver 114.114.114.114 >/home/111.txt linux-oad7:/home #
方法二,未测试.
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.