I have a executable bash script (.bash_history_cleaner) which cleans my bash history
#!/bin/bash cat /dev/null > ~/.bash_history && history -c && exit
I want to execute this script on system shutdown or restart and followed this answer which uses systemd with service name as
bash_history_cleaner.service and enabled it in systemctl. The service is up and running,
[Unit] Description=Bash History Cleaner [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/home/eka/Scripts/.bash_history_cleaner [Install] WantedBy=multi-user.target
Its intended behaviour should be to clean my bash history when either shutdown or restart. But its not working, I shutdown and restared the system many times but the script is not executed. How do we execute a bash script before shutdown using systemd?