不是全路径问题,加全路径 和 cd到脚本所在目录都试过了,nohup和在末尾加&也试过了,都不行。以下是运行结果:
[w@localhost ~]$ systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
Active: active (exited) (Result: exit-code) since 六 2016-10-15 14:38:49 CST; 2min 0s ago
Process: 933 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
Main PID: 948 (code=exited, status=1/FAILURE)
Tasks: 0 (limit: 512)
CGroup: /system.slice/rc-local.service
10月 15 14:38:49 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
10月 15 14:38:49 localhost.localdomain systemd[1]: Started /etc/rc.d/rc.local Compatibility.
10月 15 14:38:49 localhost.localdomain systemd[1]: rc-local.service: Main process exited, code=exited, status=1/FAILUR
如果在开机状态下运行systemctl start rc-local.service是没有问题的,状态会是Active: active (running) 。