Linux platform autorun

From ESS-WIKI
Jump to: navigation, search

sysvinit

1. Edit /etc/rc.local directly,eg:
  1. !/bin/sh -e
    #
    # rc.local

/usr/bin/test-service.sh

exit 0

2.use update-rc.d cmd to enable service:

touch  /etc/init.d/test_service

update-rc.d test_service defaults 97

systemd

1.create and edit /opt/test-service.sh

eg,cat test-service.sh

  1. /bin/sh

echo "Systemd service test!"

2.create and edit /etc/systemd/system/test_service.service

eg,cat test_service.service

[Unit]

Description=Systemd service test

After=syslog.target network.target

Before=time-sync.target

 

[Service]

Type=oneshot

ExecStart=/opt/test-service.sh


[Install]

WantedBy=multi-user.target

3.use systemctl cmd to enable service

systemctl enable test_service.service