Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Startup script giving me a headache.

Status
Not open for further replies.

nerbonne

Technical User
Dec 11, 2006
99
US
Ok, I wrote a script that does exactly what I want, but for the life of me, I cannot get it to run at bootup. I put the script in /etc/init.d/ and linked it in the /etc/init.d/boot.d directory using "ln -s ../boot.backups S15boot.backups".

Then I rebooted. I was sure this would work, but it doesn't?

Here is the contents of my script. Maybe you can point out where I went wrong? Permissions on the script are 755 just like most other boot scripts in the init.d directory.

-----------------
#!/bin/sh

# Remove existing rsnapshot config in case multiple backups are configured on this machine.
rm -rf /etc/rsnapshot.conf

# Move in the config that we need.
cp /etc/kb6/rsnapshot.conf /etc/rsnapshot.conf

# Run rsnapshot to rotate and download the new backups.
/usr/local/bin/rsnapshot daily

# Send an email to let everyone know the backups were done.
ssh root@server_here.net /root/cpbackups_complete
 
Just a couple of shots in the dark...

Have You made the script executable ( chmod +x boot.backups ) ?

Are You shure your system is ready to run the backupscript
as early in the startup as at S15?
 
Thanks for the reply.

It is executable, but I will re-verify.

About being S15, I don't know. It is the last of the boot scripts, how can I start it later (5 minutes or so is fine).
 
nerbonne,

It might help you to take a look at "man chkconfig".

See the "RUNLEVEL FILES" section where it talks about the need for two or more commented lines.

Hope that helps,
--
ZaSter
 
Ok, I added the two lines for chkconfig, and then ran "chkconfig --add boot.backups" and I get the output:

boot.backups: unknown service

So I guess my question is, how do I add it as a service? I am using SUSE 10 if that helps.
 

I'm not sure, but I think SUSE 10 uses "chkconfig -a " to add the service to all run levels. And to limit the run levels to level 3 and level 5 for example would be:

chkconfig boot.backups 35

That work?



 
Is the ssh failing? Is that how you know?

ssh needs the local network/default gateway to be up in order to run.
 
Have you tried setting it to S99 rather than S15 so that it will start as late in the bootup process as possible? I saw that suggestion initially and it seems to make the most sense.


pansophic
 
A correctly formed startup script should have at least a "start" and "stop" section to take care of the two events.

below is a structure of a correctly formed startup script
Code:
#!/bin/sh

case "$1" in
  start)
    /path_to_command/command_to_run_at_start
    ;;
  stop)
    /path_to_command/command_to_run_at_stop
    ;;
  *)
    echo "Usage: $(basename $0) <start|stop>"
    ;;
esac

In your case I suggest you create a script, make it executable and call it from /etc/rc.local

QatQat

QatQat

If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top