Ubuntu16.04程序自启动

试过修改/etc/rc.local文件,但是启动无效。

目前试过行之有效的方式如下:

参考:https://www.aliyun.com/jiaocheng/186625.html

在终端执行 gnome-session-properties命令

添加之后

这样的方式对于需要Root权限的程序来说,无法获取权限。

可以使用以下脚本, 上面gnome启动该脚本,这样启动的ProcessMoniter就有Root权限了:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          land.sh
# Required-start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the svnd.sh daemon
# Description:       starts svnd.sh using start-stop-daemon
### END INIT INFO
 
#任务脚本
#进入要执行脚本目录
cd "$(dirname "$0")"
#取得root权限,'admin'为密码,不用加引号,'ls'无实际作用
echo admin|sudo -S ls
#执行脚本./bin/mywork,sudo -S需要加上
sudo -S ./ProcessMoniter
#任务脚本
原文地址:https://www.cnblogs.com/zhehan54/p/9634594.html