I am running ubuntu 11.10 in a virtual machine (VirtualBox) to learn more about development in linux. I am using a git repository to save my work and have written a script to bundle my work up and save it to the shared folder for use while the virtual machine is not running.
I would like to automatically run this script before shutdown so that my work is always available if the vm is off (currently I have to manually run the script).
I don't know if upstart is the best way to accomplish this, but this is the config that I wrote as a test:
description "test script to run at shutdown"
start on runlevel [056]
task
script
touch /media/sf_LinuxEducation/start
sleep 15
touch /media/sf_LinuxEducation/start-long
end script
pre-start script
touch /media/sf_LinuxEducation/pre-start
sleep 15
touch /media/sf_LinuxEducation/pre-start-long
end script
post-start script
touch /media/sf_LinuxEducation/post-start
sleep 15
touch /media/sf_LinuxEducation/post-start-long
end script
pre-stop script
touch /media/sf_LinuxEducation/pre-stop
sleep 15
touch /media/sf_LinuxEducation/pre-stop-long
end script
post-stop script
touch /media/sf_LinuxEducation/post-stop
sleep 15
touch /media/sf_LinuxEducation/post-stop-long
end script
The result is that only one touch is accomplished (the first touch in pre-start). What do I need to change to see one of the touches after the sleep to work? Or Is there an easier way to get this accomplished?
Thanks in advance.
test.confis just a random filename. You could just as easily usewhatEverYouWant.conf. Your comment also shows that you didn't read the "Cookbook" mentioned in the answer. If you look in section 4.2 the Job Configuration File is more thoroughly explained. – Tiris Mar 02 '13 at 06:50RUNLEVEL=0to catch only shutdown orRUNLEVEL=[06]to catch shutdown and reboot. In either case, that would go right afterstarting rc– Tejay Cardon Apr 14 '15 at 19:49