How To Run Commands At Shutdown In Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/run-commands-shutdown-linux/
PINTEREST
PINTEREST
INSTAGRAM

Linux operating system provides a lot of different ways to manage system status like startup, running levels, shutdown. Old type SysVinit manager provides run levels for Linux systems. Systemd provides more convenient system status management.

Run Command With SysVinit

We will use old style SysVinit to fire commands at shutdown. As we know Linux system file scripts in /etc/rc6.d when shutting down. So we will add our script to there. Below you can the script.

We can call this script runatshutdown and put it to /etc.init.d/ .

LEARN MORE  How To List All Partitions Of A Disk In Linux

Run Command With Systemd

Systemd is modern way of managing system services and status. Simply putting following config to the /usr/lib/systemd/system-shhutdown will make our command run.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/run-commands-shutdown-linux/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)