How to run a shell script at startup

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

    A simple approach is to add a line in /etc/rc.local :

    /PATH/TO/MY_APP &
    

    or if you want to run the command as a special user :

    su - USER_FOOBAR -c /PATH/TO/MY_APP &
    

    (the trailing ampersand backgrounds the process and allows the rc.local to continue executing)

    If you want a full init script, debian distro have a template file, so :

    cp /etc/init.d/skeleton /etc/init.d/your_app
    

    and adapt it a bit.

提交回复
热议问题