Sign up ×
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 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/ /etc/rc0.d/
sudo ln -s /etc/init.d/ /etc/rc6.d/

Moreover, I made the script executable:

sudo chmod +x /etc/init.d/

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

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

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.