I created a small script backup_files.sh and placed it in /etc/init.d:#/bin/shlogfile=/media/verbatim/logdate >> $logfilersync -av /home/philipp/Documents /media/verbatim/ >> $logfileI would like this script to be executed whenever the computer is rebooted or shut down, so I did the following:sudo ln -s /etc/init.d/backup_files.sh /etc/rc0.d/backup_files.shsudo ln -s /etc/init.d/backup_files.sh /etc/rc6.d/backup_files.shMoreover, I made the script executable:sudo chmod +x /etc/init.d/backup_files.shI tried the script manually and it worked just fine. However, if I shutdown or reboot my computer, it is apparently not executed.Does anybody see what I'm doing wrong?Note: I'm using Xubuntu 11.10.
Running script before shutdown seemingly not working
ubuntu;init script;sysvinit
Finally found out that I had to give them particular file names:sudo ln -s /etc/init.d/backup_files.sh /etc/rc0.d/K10backup_files.shsudo ln -s /etc/init.d/backup_files.sh /etc/rc6.d/K10backup_files.shThe scripts in /etc/rc0.d and /etc/rc6.d are executed at the time of shutdown and reboot respectively. The scripts with their name starting with capital k are executed with an argument stop while those starting with capital S are executed with argument start. Moreover the execution of files is done in lexicographical order.The files in these runlevels are named as:[K | S] + nn + [string]nn -> a two digit numberstring -> must be a lowercase stringMore about linux runlevels can be found here