在网上看了很多方法,都没有奏效。
本文方法:
1、编写test.sh脚本
#!/bin/bash
### BEGIN INIT INFO
# Provides: starter
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start starter
# Description: start starter
### END INIT INFO
#chkconfig: 2345 80 90
#description:auto_run
su --l username
cd /path/
python test.py
exit 0
2、在ubuntu左上角搜索框查找Startup Applications 点击
点击add
Name:定义名字,test
Command:/usr/bin/gnome-terminal -x bash -c “/path/test.sh;exec bash”
#其中/usr/bin/gnome-terminal为开机打开终端。
bash -c “/path/test.sh;exec bash” 运行脚本。
Comment:说明,随意填写,可不填。
点击保存。
3、reboot测试。