Start Stop Restart


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Start Stop Restart
# 1  
Old 01-02-2009
Start Stop Restart

I'm wondering how I should make a script that can start, stop, and restart another script.
What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH, DASH, KSH, PERL installed.
Does anyone have any ideas?
# 2  
Old 01-02-2009
have a look at the runlevel scripts in /etc/init.d; /etc/rcx.d (depends on your os!). these scripts are doing exactly what you want to do...
# 3  
Old 01-02-2009
well, I don't even have those, since i have ubuntu. I think its init.d in ubuntu. I'll try and find a simple one.
# 4  
Old 01-02-2009
Ok, i'm really confused.
I just haven't spent enough time scripting to be able to do complex tasks.
I don't want to ask too much of you, but let's say I want it to control the script
/home/bakes/control.sh ?
does anyone feel like making an example for me?
# 5  
Old 01-02-2009
there are runlevel scripts in ubuntu... but i've only an old version to look at (6.06). i've posted you the crond start/stop script.

Code:
#!/bin/sh
# Start/stop the cron daemon.
#
### BEGIN INIT INFO
# Provides:          cron
# Required-Start:    $syslog $time
# Required-Stop:     $syslog $time
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Regular background program processing daemon
# Description:       cron is a standard UNIX program that runs user-specified 
#                    programs at periodic scheduled times. vixie cron adds a 
#                    number of features to the basic UNIX cron, including better
#                    security and more powerful configuration options.

### END INIT INFO


test -f /usr/sbin/cron || exit 0

#LSBNAMES='-l'  # Uncomment for LSB name support in /etc/cron.d/

. /lib/lsb/init-functions

case "$1" in
start)	log_begin_msg "Starting periodic command scheduler..."
        start-stop-daemon --start --quiet --pidfile /var/run/crond.pid --name cr
on --startas /usr/sbin/cron -- $LSBNAMES
        log_end_msg $?
	;;
stop)	log_begin_msg "Stopping periodic command scheduler..."
        start-stop-daemon --stop --quiet --pidfile /var/run/crond.pid --name cro
n
        log_end_msg $?
        ;;
restart) log_begin_msg "Restarting periodic command scheduler..."
        start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/crond.pid 
--name cron
        start-stop-daemon --start --quiet --pidfile /var/run/crond.pid --name cr
on --startas /usr/sbin/cron -- $LSBNAMES
        log_end_msg $?
        ;;
reload|force-reload) log_begin_msg "Reloading configuration files for periodic c
ommand scheduler..."
	# cron reloads automatically
        log_end_msg 0
        ;;
*)	log_success_msg "Usage: /etc/init.d/cron start|stop|restart|reload|force
-reload"
        exit 1 
        ;;
esac
exit 0

# 6  
Old 01-02-2009
at least that one's smaller than the apache one i was looking at!
# 7  
Old 01-02-2009
I can honestly make no sense of that, I'm dyslexic and unless it's laid out really well, I just find it semi-impossible. As well as that, i'm not entirely sure what this does, other than calling start-stop-daemon to kill/start the process
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Can't stop/restart postfix - pid associated with another process

This issue could happen to any other service but in this case its commssioning Postfix - it seems i can't stop postfix as the PID relates to another service - i've delete the 'master.lock' but to no available - any ideas, memeory commands etc ? thanks in advance ps. the serve is in Production so... (2 Replies)
Discussion started by: stevie_velvet
2 Replies

2. UNIX for Dummies Questions & Answers

factor [start[stop]

Another question for you guys! This is so fun. So I am playing around with the factor operation. I read in "man factor" that you can actually print a list of primes in between a range, using the syntax factor ] However, every time I enter two values, it just returns the factored value.... (1 Reply)
Discussion started by: statichazard
1 Replies

3. Shell Programming and Scripting

Help scripting to start, check, and restart processes

Here it goes from my unexperienced point of view. I am using CentOS 5.6. I have a Java based server that needs to be running 24/7/365. To begin from the machine the server is on rebooting; I SSH in to a shell, cd to the server dir, screen -S server1, and execute ./exec (listed below) in the screen.... (12 Replies)
Discussion started by: MacG32
12 Replies

4. UNIX for Dummies Questions & Answers

Stop/Start vs. Restart

Is there any functional difference between: issuing separate stop/start commands like this; super (handler) (instance) stop super (handler) (instance) start versus issuing a single recycle command like this; super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies

5. Shell Programming and Scripting

guarantee to start before restart...

Hi All, is there a way or script that i can check my AIX 5.3 OS will restart before i made restart? is there a script that can check all the startup files are ok before restarting. it is because i was stuck last time when i restart my PC because some startup files were missing:o. (2 Replies)
Discussion started by: malcomex999
2 Replies

6. UNIX for Advanced & Expert Users

Log 'syslog start/stop/restart' messages

How can I tell my syslog.conf to log "syslog start/stop/restart" messages on a Solaris box? (1 Reply)
Discussion started by: SunnyK
1 Replies

7. AIX

How to start/stop/restart NFS on AIX

Hi, Very new to aix How to start/stop/restart NFS on AIX thanks, (2 Replies)
Discussion started by: jredx
2 Replies

8. HP-UX

ypbind start/stop

Hi, How to start or stop ypbind on HP-UX machine. Searched a little but could not find. thanks, (2 Replies)
Discussion started by: jredx
2 Replies

9. AIX

Start Stop Apache

I am in the process of reorging my Lawson db. I need to turn off the RMI server...not a problem. However my instructions also state that I must also shutdown my Servlet Container....I believe it is Apache. I have looked in /usr/apache/bin/apachectl What is the command for stopping and... (2 Replies)
Discussion started by: MILLERJ62
2 Replies

10. UNIX for Dummies Questions & Answers

Start/Stop Script

I'm a newbie to the Unix world Help! I have to maintain a host of Sybase database servers sitting on Unix Sun Solaris 8...I've been tasked with finding/creating a way to auto start/stop Unix via unix commands, specifically when the Unix servers need to be restarted we want Sybase to start... (2 Replies)
Discussion started by: jjv1
2 Replies
Login or Register to Ask a Question