8

Calling a script on machine shutdown

view full story
linux-howto

http://unix.stackexchange.com – I want to call a script on machine shutdown and restart. I have written code like #! /bin/bash #chkconfig: 0 6 1 1 #description: Description of the script # processname: killfoo # this script starts and stops foo # Some things that run always LOG_FILE="/tmp/killfoo.log" log() { while IFS='' read -r line; do echo "$(date) $line" >> "$LOG_FILE"; done; }; exec > >(tee >(log)) # Carry out specific functions when asked to by the system case "$1" in start) echo "Nothing to done" ;; stop) echo "Stopping script killfoo" pkill -9 foo >> $LOG_FILE 2>&amp (HowTos)