How to run a script as a service in UBUNTU

后端 未结 1 1758
我寻月下人不归
我寻月下人不归 2021-01-05 21:57

I have a script which normally i run using ./myscript.sh(contain java run command) on linux. Now i want to make it as a service so it run automatically after machine restart

相关标签:
1条回答
  • 2021-01-05 22:30

    You need to write systemd service file.

    Simplest script looks like this:

    [Unit]
    Description=Virtual Distributed Ethernet
    
    [Service]
    ExecStart=/usr/bin/YOUR_SCRIPT
    
    [Install]
    WantedBy=multi-user.target
    

    Also you need: systemctl daemon-reload after creating new service.

    0 讨论(0)
提交回复
热议问题