On Monday 22 May 2006 10:18, Sergey Mkrtchyan wrote:
Leendert Meyer wrote:
Why not start from the skeleton, change the start and stop sections to do something simple, like: echo "$(date +%FT%T%z): FOO started" >> /tmp/FOO.log and echo "$(date +%FT%T%z): FOO stopped" >> /tmp/FOO.log
(log files normally would go to /var/log/, but since your playing, I think /tmp/ is better)
Dear Leendert, I was playing these days with it, understood a lot, but again there is some small problems I have.
Here what I have done: In the skeleton I just changed the appropriate parts to
Here's a extremely minimalistic 'skeleton', stripped from comments: ----<cut here>---- #!/bin/sh ### BEGIN INIT INFO # Provides: FOO # Required-Start: $syslog $remote_fs # Should-Start: $time ypbind sendmail # Required-Stop: $syslog $remote_fs # Should-Stop: $time ypbind sendmail # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: FOO XYZ daemon providing ZYX # Description: Start FOO to allow XY and provide YZ # continued on second line by '#<TAB>' # should contain enough info for the runlevel editor # to give admin some idea what this service does and # what it's needed for ... # (The Short-Description should already be a good hint.) ### END INIT INFO . /etc/rc.status rc_reset case "$1" in start) echo -n "Starting FOO " echo "$(date +%FT%T%z): FOO started" >> /tmp/FOO.log # false rc_status -v ;; stop) echo -n "Shutting down FOO " echo "$(date +%FT%T%z): FOO stopped" >> /tmp/FOO.log # false rc_status -v ;; restart) $0 stop $0 start rc_status ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac rc_exit ----<cut here>----
I am a newbie and got a very little experience with shell scripting,
Hmm, I assumed you know a bit of shell-script programming. However, if you're a programmer, you might learn it quickly (you know best if you could).
maybe I should leave this for a better times?
Well, you learning curve just got a bit steeper... ;) You might as well add 'man bash' to your RTFM list. But there are some shell-scripting tutorials on the net. However I can't recommend any, because I don't know any. ;) Here's a starting point: http://en.wikipedia.org/wiki/Bash (I like Wikipedia more and more...). There are some links at the bottom that might interest you. Cheers, Leen