---
title: "在Linux中开机自动运行普通用户脚本程序"
author: "superich2008"
date: "2014-06-03T11:27:34Z"
tags: []
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2014-06-03T11:27:34Z"
id: 2075375
url: "https://superich2008.iteye.com/blog/2075375"
---

Linux在启动时，会自动执行<span style="color:red">/etc/rc.d</span>目录下的初始化程序，因此我们可以把启动任务放到该目录下:

1、因为其中的<span style="color:blue">rc.local</span>是在完成所有初始化之后执行，因此我们可以把启动脚本写到里面；
2、用root账号登陆Linux，vi /etc/rc.d/rc.local编辑文件，在最后加入需要执行的脚本程序：su -l <span style="color:blue">$username</span> -c "/nexus/nexus-2.8.0-05/bin/nexus start"


参考：<http://www.php100.com/html/webkaifa/Linux/2008/0526/2780.html>