The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Log 'syslog start/stop/restart' messages SunnyK UNIX for Advanced & Expert Users 1 07-14-2008 11:16 AM
How to start/stop/restart NFS on AIX jredx AIX 2 06-25-2008 04:00 AM
How can I make a program start up automatically after the computer restart/startup? munna_dude Shell Programming and Scripting 1 02-07-2007 09:13 AM
Start Stop Apache MILLERJ62 AIX 2 12-27-2005 05:40 PM
Stop/Start proftpd Lomic UNIX for Dummies Questions & Answers 1 12-09-2004 09:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
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 (permalink)  
Old 01-02-2009
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,910
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 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
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 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
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 (permalink)  
Old 01-02-2009
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,910
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 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
at least that one's smaller than the apache one i was looking at!
  #7 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0