写这篇文章的目的是因为网上的文章A抄B,B抄C,自己写的什么玩意都不知道就抄,特此记录便于日后查阅。
首先打开rc.local文件,代码如下:
$ sudo vim /etc/rc.local
在里面加入你想要开机就执行的命令(这里我是开机自启动redis),代码如下:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
nohup /usr/local/programs/redis/src/redis-server /usr/local/programs/redis/redis.conf &
exit 0
给 rc.local 文件可执行的权限,代码如下:
$ sudo chmod +x /etc/rc.local
到此Ubuntu加入开机自启动命令(rc.local)