Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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

Capital K tells the system to run the script when shutting down. The number 10 indicates the priority of this script (I think priority between 00 and 99, the lower the number the higher the priority (no guarantee for that)).

share|improve this answer

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.