zoukankan      html  css  js  c++  java
  • OpenSUSE配置开机启动


    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.
  • 相关阅读:
    基于风险集成 Risk-Based
    基于消息(事件)集成 Message-Based/Event-Based
    如何保证系统测试的完备性?
    1.1 功能测试(功能)
    问:给你一个网站,你如何测试?
    问:你在测试中发现了一个bug,但是开发经理认为这不是一个bug,你应该怎样解决?
    4.如何重新加载 Spring Boot 上的更改,而无需重新启动服务器?
    什么是 JavaConfig?
    Spring Boot 有哪些优点?
    .Redis中的常用命令哪些?
  • 原文地址:https://www.cnblogs.com/bleachli/p/12802971.html
Copyright © 2011-2022 走看看