I created a small script backup_files.sh and placed it in /etc/init.d:

date >> $logfile
rsync -av /home/philipp/Documents /media/verbatim/ >> $logfile

I 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.sh
sudo ln -s /etc/init.d/backup_files.sh /etc/rc6.d/backup_files.sh

Moreover, I made the script executable:

sudo chmod +x /etc/init.d/backup_files.sh

I 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.

1 Answer 1


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.sh
sudo ln -s /etc/init.d/backup_files.sh /etc/rc6.d/K10backup_files.sh

The 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 number
string -> must be a lowercase string

More about linux runlevels can be found here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .