• 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.
  • 相关阅读:
    “sockaddr”: “struct”类型重定义的错误的解决办法《转》
    2019年车险
    tinylib
    命令行利用ffmpeg实现rtmp推流《转》
    Inno setup 判断系统32位还是64位
    vs2015编译OBS-Studio21.1.12
    啃OBS源码-界面汉字
    百年孤独人物关系1
    windows命令行查看文件MD5
    python 玩爬虫安装了一大堆第三方库
  • 原文地址:https://www.cnblogs.com/bleachli/p/12802971.html
Copyright © 2020-2023  润新知