How to run a shell script at startup

前端 未结 21 1796
伪装坚强ぢ
伪装坚强ぢ 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:16

    Edit the rc.local file using nano or gedit editor and add your scripts in it. File path could be /etc/rc.local or /etc/rc.d/rc.local.

    sudo nano /etc/rc.local
    

    This is the edit:

    #!/bin/sh
    /path-to-your-script/your-scipt-name.sh
    

    once done press ctrl+o to update, pressEnter then ctrl+x.

    Make the file executable.

    sudo chmod 755 /etc/rc.local
    

    Then initiate the rc-local service to run script during boot.

    sudo systemctl start rc-local
    

提交回复
热议问题