
Sometimes, it can be useful to organize a lot of shell commands into 1 script. That scripts represents a single, atomic action. For example: starting up a JBoss server.
I've created a custom script to execute my action faster
/etc/init.d/mycustomscript
#! /bin/sh # /etc/init.d/mycustomscript # case "$1" in start) echo "Starting mycustomscript" # do # some # stuff # here exit 0 ;; stop) echo "Stopping mycustomscript" # do # some # stuff # here exit 0 ;; restart) echo "Restarting mycustomscript" # do # some # stuff # here exit 0 ;; *) echo "Usage: /etc/init.d/mycstomscript {start|stop|restart}" exit 0 ;; esac exit 1
Now, you can start/stop/restart your script using:
<a href="mailto:jochen@baileys">jochen@baileys</a> ~ $ sudo /etc/init.d/mycustomscript start
Or to make it even more faster, you can use your bash history: CTRL + R
(reverse-i-search)`sudo /et': sudo /etc/init.d/mycustomscript start
Add new comment