mac下redis开机自启
首先在~/Library/LaunchAgents创建文件org.redis.redis-server.plist,文件内容为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>redis-server</string>
<key>Program</key>
<string>/usr/bin/redis-server /etc/redis.conf</string>
<key>KeepAlive</key><true/>
</dict>
</plist>
然后依次执行命令:
sudo chown root:wheel ~/Library/LaunchAgents/org.redis.redis-server.plist
sudo chmod +x ~/Library/LaunchAgents/org.redis.redis-server.plist
launchctl load -w ~/Library/LaunchAgents/org.redis.redis-server.plist
需要说明的是,/etc/redis.conf配置文件中需要把“daemonize no”设置为“daemonize yes”,这样redis启动时会在后台运行。
【版权申明】未经博主同意,谢绝转载!(请尊重原创,博主保留追究权) https://www.cnblogs.com/facetwitter/p/9132688.html