ubuntu开机自动执行脚本
2014-09-04 10:43
357 查看
想要在开机的时候用指定的用户来启动脚本可以结合rc.local文件和su命令。
su命令:
su – 用户名 -c 命令
‘su’ 和 ‘su -’ 的区别是’su -’切换用户的同时也切换了环境变量,所以一般推荐使用 ‘su -’
‘-c’ 后面接要执行的命令
则以上命令实现先切换到指定用户,执行命令,再切换回原来的用户。
rc.local文件一般为开机最后执行的。编辑/etc/rc.local文件:
view
source
su命令:
su – 用户名 -c 命令
‘su’ 和 ‘su -’ 的区别是’su -’切换用户的同时也切换了环境变量,所以一般推荐使用 ‘su -’
‘-c’ 后面接要执行的命令
则以上命令实现先切换到指定用户,执行命令,再切换回原来的用户。
rc.local文件一般为开机最后执行的。编辑/etc/rc.local文件:
view
source
01 | #!/bin/sh -e |
02 | # |
03 | # rc.local |
04 | # |
05 | # This script is executed at the end of each multiuser runlevel. |
06 | # Make sure that the script will "exit 0" on success or any other |
07 | # value on error. |
08 | # |
09 | # In order to enable or disable this script just change the execution |
10 | # bits. |
11 | # |
12 | # By default this script does nothing. |
13 |
14 | #以下为加入的脚本 |
15 | su - kurenai -c /home/kurenai/tomcat/bin/startup .sh |
16 | # |
17 |
18 | exit 0 |
19 | ~ |
20 | ~ |
21 | ~ |
相关文章推荐
- Ubuntu 开机自动执行脚本
- Ubuntu 开机自动启动roscore命令 自动打开终端执行脚本命令
- ubuntu 配置开机自动执行脚本
- ubuntu启动流程及开机执行shell脚本
- ubuntu yah3c 自动认证可执行脚本
- ubuntu下开机自动运行脚本以及定时任务的处理
- ubuntu下开机自动运行脚本、定时运行脚本
- ubuntu设置开机自动登陆与登录自动运行脚本
- Android 开机自动执行脚本
- Ubuntu杂谈(十三)开机自动执行命令行的命令
- ubuntu下开机自动运行脚本、定时运行脚本
- Linux开机自动执行脚本
- ubuntu shell脚本开机自动运行的方法
- Linux 开机自动执行脚本设置
- (参考)ubuntu shell脚本开机自动运行的方法
- ubuntu下开机自动运行脚本、定时运行脚本 .
- ubuntu下开机自动运行脚本以及定时任务的处理
- ubuntu 修改ssh远程主机名称,mac开机运行命令,静默方式启动virtual box虚拟机,静默执行run脚本
- ubuntu shell脚本开机自动运行的方法