• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need help creating a shell script

M8triX

Member
I have limited experience dealing with linux, what i want to do is create a shell script that if our linux servers goes down that i can restart the server services without having to change directories and then do the serverstart command.

The servers will once and awhile give thus forcing me to go through 1 by 1 to each server and goign into the app directory and starting the services again.

Is there a way to kill a process without having to get the proc id and just use for instance somethign like this

kill -9 /etc/travel/wasp65.uat?

and how shall i run this script or create it.
 
Proper services have init scripts in /etc/init.d, so just run it with the full path like '/etc/init.d/whatever restart'.
 
Yeah if you're just restarting a few services that have init scripts just use a few "/etc/init.d/servicename restart" lines in a script.

If you want to easily restart all the services on a server, just reboot the server or something.

Sometimes I use DJB's daemontools to help monitor and restart services, though if you're not that familiar with scripting and shell work, it may be much more complex to get setup initially than you'd prefer. The upside is that once it works, it can be handy to automatically or semi-automatically handle service initiation, monitoring, and restart.
http://cr.yp.to/daemontools.html

On the other hand if the service is smart enough to not run duplicates of itself you could always just have a cron job run the service's init script every 5 minutes which would (in the useful case of possibilities) do nothing much if it was already running, and restart it for you if it wasn't running. Obviously this doesn't help if it'll start multiple times or if it dies in a way that needs cleanup so that the init script can reinit it successfully.

Of course you could do some higher level monitoring of the services to test that they actually *function* at a high level (rather than just ensuring that the process is running) using some kind of monitoring infrastructure that can then manage failures and create alerts etc. if something is wrong. e.g. SNMP, whatever.
 
Back
Top