• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Linux init.d scripts

darmstadt

I live on CUK
Joined
Jul 6, 2005
Messages
20,014
Likes received
4,111
Thanks received
1,499
Location
The Eurozone
In order to stop and start applications automatically on Debian I created a script based on the skeleton in /etc/init.d and then ran the update-rc.d command on it:

update-rc.d test_server1 start 99 3 . stop 01 0 6

This created the relevant links in /etc/rc3.d to start it and in /etc/rc0.d and rc6.d to stop it. The problem seems to be that at system boot time it doesn't seem to run the script but at system shutdown it does. You can run the script manually but need to provide a parameter (start/stop/restart/status) so I know it is working and as can be seen, the shutdown is fine. I'm just wondering as to why the start is not being picked up.

The only differences between the stop and start is that start uses the start-stop-daemon, i.e.


start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME --test > /dev/null \
|| return 1
start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME -- \
|| return 2


whereas stopping it uses commands sent to the server as start-stop-daemon justs gets the pid and then kills the process but I want it to stop cleanly, i.e.

$DAEMONSTO $NAME -user adminuser -password password

The restart just calls the above 2 steps and works fine. Just wondering if I missed something somewhere...TIA.
 
Is the chkconfig line in the top of the script. I think that needs to be there it won't get run.
 
sorry -- I run two Ubuntu server and one CentOS - you'd think I'd know that.

have you tried just:

update-rc.d test_server1 start 99 3 4 5 . stop 99 0 1 6 .
 
Sorry to state the bleedin obvious but did you make this script runnable?

chmod 755 /etc/init.d/blah

type of thing?
 
Did you get this sorted? Let us know. :tantrum:

End of last week as a matter of fact, need to fully test it but looks like its working. I just did:

# update-rc.d test-server1 defaults 01 99

It would be nice to see the messages in the logs but the server starts and stops. Cheers.
 

Advertisers

Back
Top