Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Although I have created a file in /etc/rc0 directory to get it run at startup I does not execute. On the contrary when same file is created at /etc/rc6 directory, it gets executed upon shuting down.

K99startup.sh -> ../init.d/startup.sh*

I am using Ubuntu 12.04

share|improve this question

migrated from stackoverflow.com Nov 2 '12 at 9:11

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers 3

up vote 1 down vote accepted

You can call the script from /etc/rc.local which is the correct place for custom scripts to run at startup.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/local/bin/your-script

exit 0
share|improve this answer
    
What is the exact difference way os usage of this file from using os run-level directory files? –  mmc18 Nov 2 '12 at 8:10
    
I have created same file at both /etc/rc2.d /etc/rc3/d folder but it does not either. I am testing this functionality via reboot command. –  mmc18 Nov 2 '12 at 9:04
add comment

runlevel 6 is used during reboot. http://www.debian-administration.org/articles/212

try using /etc/rc2.d and name it S99startup.sh the S prefix is for Start and the K prefix is for Kill.

share|improve this answer
add comment

That's normal. Linux runlevel 6 is reboot/shutdown. What you're looking for is runlevel 3 or/and 5.

The standard tools for managing startup scripts are chkconfig or update.rc. But if you want to be "on the edge" you can use upstart - which was presented in Ubuntu some time ago.

Upstart jobs are located under /etc/init- you just have to copy an existing job and use it as example/template to write your own job for your script. Most of the people recommend looking at /etc/init/mysql.conf and start from there.

share|improve this answer
add comment

Your Answer

 
discard

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.