NameSilo

Help in making one shell script

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
is it even possible or am i asking for a too complicated thing?
 
0
Close
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
Close
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
Close
Generally I'd rather recommend to investigate why the services crash than only solve it by restarting them.
 
0
Close
champ_rock,

Why would you need restart service so often?
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

New: watch any domain
You can now watch domains on NamePros. We check each one and notify you when something changes. Search for a domain and press Watch on...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back