centos7 編寫測試服務
bak.sh腳本內容:centos
cp -a /etc/sysconfig /app/sysconfig-bak >> /dev/null bak腳本要加執行權限
服務Unit文件示例bash
[Unit] Description=backup /etc Requires=atd.service [Service] Type=simple ExecStart=/bin/bash -c "echo /lib/systemd/system/bak.sh|at now" [Install] WantedBy=multi-user.target
運行級別app
ls /usr/lib/systemd/system/*.target
`運行級別: 0 ==> runlevel0.target, poweroff.target 1 ==> runlevel1.target, rescue.target 2 ==> runlevel2.target, multi-user.target 3 ==> runlevel3.target, multi-user.target 4 ==> runlevel4.target, multi-user.target 5 ==> runlevel5.target, graphical.target 6 ==> runlevel6.target, reboot.target `
設置默認運行級別ide
systemctl set-default multi-user.target 等同於建立軟連接: ln -s /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target 刪除軟連接使用原來默認運行級別 rm -f /etc/systemd/system/default.target