Dynadot โ€” .com Registration $8.99

Help in making one shell script

Spaceship Spaceship
Watch
Impact
91
hi

i am looking for a shell script that will restart some basic services at given intervals.

I am looking to restart mysql service, lighttpd service, ftp service, and any other service that you think is critical to the working of a VPS (i have a proxy network)

I am looking for this script becasue my proxies sometimes tend to overload the server due to which the server crashes. will this script work in this scenario??

please post the exact coding because i am a noob to linux command line and will probably get more confused if there are any changes that need to be made

also, is it possible to send a mail of its results to my email id? if so, how to do it (if it requires relatively simple coding)

thanks a lot
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
is it even possible or am i asking for a too complicated thing?
 
0
•••
So you want a script that will restart or stop a service if the load goes up in the server?

A quick way to find is a little googling.
 
0
•••
Just take the service take the commands you want to run eg.

/etc/init.d/lighttpd restart
/etc/init.d/mysqld restart

and add them to a text file like this:
#!/bin/sh
# This is a comment, the above line means that we will use sh to interpret this script

# restart lighttpd and pipe the output to /dev/null so you don't get a email from cron.
/etc/init.d/lighttpd restart >> /dev/null

#restart mysql
/etc/init.d/mysqld restart >> /dev/null

#end of script

now run chmod a+x restart_services.sh
to make the script executable

and add it to your cron jobs, hackish and simple. :P
 
0
•••
Generally I'd rather recommend to investigate why the services crash than only solve it by restarting them.
 
0
•••
champ_rock,

Why would you need restart service so often?
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back