sudo vim /etc/rc.local
sudo /etc/rc.local

sudo systemctl enable rc-local.service
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

Refer to:


#!/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.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

export TZ=Asia/Shanghai

echo sleep $interval secs...
sleep $interval
_MSG=`hostname -I | awk '{print "pi: "$1}'`
curl --get --data-urlencode "text=$_MSG, date: `date`" &

exit 0

设置某个 service 项目开机自动启动, 例如已经可以使用 sudo service slapd start 启动的 OpenLDAP 可以用如下命令开机自动启动:

sudo chkconfig slapd on

# 屏幕输出
➜ lane@vbox ~/open-ldap-script git:(master) sudo chkconfig slapd on
Note: Forwarding request to 'systemctl enable slapd.service'.
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/slapd.service.
Write a Comment