Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have setup a auto scaled load balanced application on Amazon EC2. I want to collect the logs from the auto scaled instances before automatic termination of the instances.

I have a script which transfers files from the auto scaled instances to a Centralize log server. I want to run the script on shutdown or reboot of the instances. I am using Fedora, please let me know how to run the script on shutdown after all the user process have been stopped ?

share|improve this question
Note that to do the transfer you'll have to do it before networking is shut down, otherwise you won't be able to do the transfer. – Cry Havok Oct 20 '10 at 6:25

Write an initscript that performs the task in stop(). See /usr/share/doc/initscripts-*/sysvinitfiles for details.

share|improve this answer
I created a file transferlogs with the following contents #!/bin/bash start(){ } stop() { echo -n "Shutting down logtransfer status: " cd /etc/init.d/ ./logtransfer } case "$1" in start) start ;; stop) stop ;; status) ;; restart) stop start ;; reload) ;; esac exit 0 – Santhosh S Oct 22 '10 at 8:33
chmod +x /etc/init.d/transferlogs and restarted the system. But the logs were not transferred to the other server. – Santhosh S Oct 22 '10 at 8:41
Your script is missing a lot of required boilerplate. Read that file again. – Ignacio Vazquez-Abrams Oct 22 '10 at 14:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.