I'm using Ubuntu 16.0.4
I want to run a script at shutdown
I've created a file etc/init.d/rabbitstop as below:

cp -b /home/admin1/hello /home/admin1/pritesh/hi
exit 0

And I ran

sudo chmod +x /etc/rc6.d/rabbitstop

also ran this command:

sudo ln -s /etc/init.d/rabbitstop /etc/rc0.d/K01rabbitstop

then shutdown PC and started again, but I'm not getting the file named hi at this location:


kindly suggest a solution to me

1 Answer 1


Make sure this directory exist : /home/admin1/pritesh you are using ubuntu 16.04 with systemd so create a systemd unit file in /etc/systemd/service/myunit.service

Description=my shutdown script
Before=shutdown.target reboot.target halt.target


WantedBy=halt.target reboot.target shutdown.target

then run

systemctl daemon-reload
systemctl enable myunit

shutdown , halt or reboot to see the result .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .