My laptop OS is Ubuntu 18.04,I want to Run a script command on shutdown of machine, I try many Linux's solutions,but loss! last I try this solution, It's success! so, I record it.
1. IN /lib/systemd/system/create a file cleanup.service
2.edit "cleanup.service" file
cleanup.service content
————————————————
[Unit]
Description=Run command at shutdown
Requires=network.target
DefaultDependencies=no
Conflicts=reboot.target
Before=shutdown.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/bin/bash /usr/local/bin/cleanup.sh
[Install]
WantedBy=multi-user.target
————————————————
3.reload systemd setting
sudo systemctl daemon-reload
4.enable service
sudo systemctl enable cleanup.

90257432_3078295618861843_6055967414221275136_o.jpg

arrow
arrow
    文章標籤
    shutdown ubuntu shell python
    全站熱搜

    is90057 發表在 痞客邦 留言(0) 人氣()