How to run a shell script at startup

前端 未结 21 2065
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 13:39

On an Amazon S3 Linux instance, I have two scripts called start_my_app and stop_my_app which start and stop forever (which in turn runs my

21条回答
  •  一向
    一向 (楼主)
    2020-11-22 14:24

    I refered to this blog, always sound a good choice

    https://blog.xyzio.com/2016/06/14/setting-up-a-golang-website-to-autorun-on-ubuntu-using-systemd/

    vim /lib/systemd/system/gosite.service

    Description=A simple go website
    ConditionPathExists=/home/user/bin/gosite
    
    [Service]
    Restart=always
    RestartSec=3
    ExecStart=/home/user/bin/gosite
    
    [Install]
    WantedBy=multi-user.target
    
    
    systemctl enable gosite.service
    

提交回复
热议问题