首页 Ubuntu开机自启动脚本
文章
取消

Ubuntu开机自启动脚本

创建快捷方式

  1. 进入到目录 /etc/init.d

  2. 创建以 desktop 为后缀的文件

例:idea 快捷方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /bin/sh
### BEGIN INIT INFO
# Provides:          qzpd
# Required-Start:    $syslog $time $remote_fs
# Required-Stop:     $syslog $time $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: My own service
# Description:       My own service inclued hadoop flink spark etc.
### END INIT INFO
#
# Author:            qzp
#

basedir=/home/qzp/sbin

if test -x $basedir/start-service.sh && test -x $basedir/stop-service.sh
then
  cd $basedir
else
  echo "The file $bindir/start-service.sh or $bindir/stop-service.sh is not exists!";
  exit;
fi

case "$1" in
    'start' )
        start-service.sh
        ;;
    'stop' )
        stop-service.sh
        ;;
    'restart' )
        start-service.sh
        stop-service.sh
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        ;;
esac
本文由作者按照 CC BY 4.0 进行授权