In linux, set the program to the systemctl service and start the system.
Take the nexus service as an example:
Enter/usr/lib/systemd/system, create the nexus. service file, and write the following content. For field descriptions, refer to the field description of Baidu systemctl service.
[Unit]
Description = Nexus
Afterappsnetwork.tar get remote-fs.target nss-lookup.target
[Service]
Type = forking
Environment = "JAVA_HOME =/usr/java/jdk1.8.0 _ 144"
ExecStart =/usr/local/nexus-3.7.1-02/bin/nexus start
ExecStop =/usr/local/nexus-3.7.1-02/bin/nexus stop
[Install]
Wantedbypolicmulti-user.tar get
Save and exit,
Input
Systemctl reload *. service # reload the service configuration file
Then you can start the service, systemctl start nexus. service.
Set boot start: systemctl enable nexus. service
Common systemctl commands:
Systemctl is-enabled servicename. service # query whether the service is started
Systemctl enable *. service # Start the service
Systemctl disable *. service # cancel startup
Systemctl start *. service # start the service
Systemctl stop *. service # stop the service
Systemctl restart *. service # restart the service
Systemctl reload *. service # reload the service configuration file
Systemctl status *. service # query the service running status
Systemctl -- failed # displays services that fail to be started