Server Stop, Start, Restart (Apache, SSH, MySql, Qmail)

Apache:

Q. I’m using CentOS / RHEL / Fedora Linux server and I’d like to restart my httpd server after making some changes to httpd.conf file. How do I restart httpd?

A. You can use service command to restart httpd. Another option is use /etc/init.d/httpd service script.

Login as root user and type the following commands:

Task: Start httpd server:

# service httpd start

Task: Restart httpd server:

# service httpd restart

Task: Stop httpd server:

# service httpd stop
Please note that restart option is a shorthand way of stopping and then starting the Apache HTTPd Server. You need to restart server whenever you make changes to httpd.conf file. It is also good idea to check configuration error before typing restart option:
# httpd -t
# httpd -t -D DUMP_VHOSTS

Sample output:

Syntax OK

Now restart httpd server:
# service httpd restart
Where,

  • -t : Run syntax check for config files
  • -t -D DUMP_VHOSTS : Run syntax check for config files and show parsed settings only for vhost.

/etc/init.d/httpd script

You can also use following command:
# /etc/init.d/httpd restart
# /etc/init.d/httpd start
# /etc/init.d/httpd stop

A note about Debian / Ubuntu Linux

Type the following command under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

You can also use service command under Debian / Ubuntu Linux:
# service apache2 restart
# service apache2 stop
# service apache2 start

from: www.cyberciti.biz

SSH:

Q. How do I monitor my ssh server with monit? How do I restart ssh server if it does not respond or dead due to any issues under Linux?

A. You can easily monitor Linux server or service such as OpenSSH (SSHD daemon) using monit utility.

Monitor SSH and Auto Restart If Died

Open your /etc/monitrc or /etc/monit/monitrc file:
# vi /etc/monit/monitrc
Append following code:
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

Save and close the file. Make sure you set /var/run/sshd.pid and /etc/init.d/ssh as per your Linux distribution. These values are valid for Debian / Ubuntu Linux. Restart monit to pickup the changes:
# /etc/init.d/monit restart

from: www.cyberciti.biz

Mysql:

Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).

First login as root user. Now type the following command as per your Linux distro:

A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

* To start mysql server:

/etc/init.d/mysqld start

* To stop mysql server:

/etc/init.d/mysqld stop

* To restart mysql server

 /etc/init.d/mysqld restart

Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:

# service mysqld start
# service mysqld stop
# service mysqld restart

(B) If you are using mysql on Debian / Ubuntu Linux then use following command:

* To start mysql server:

/etc/init.d/mysql start

* To stop mysql server:

/etc/init.d/mysql stop

* To restart mysql server

/etc/init.d/mysql restart

from: theos.in

Qmail:

qmail-init(8) – Linux man page

Name

qmail-init – start/stop scripts for qmail

Synopsis

init.d/qmail [ start | stop | restart | status ]

init.d/qmtpd [ start | stop | restart | status ]

init.d/pop3d [ start | stop | restart | status ]

init.d/qmqpd [ start | stop | restart | status ]

init.d/qmtpd [ start | stop | restart | status ]

init.d/smtpd [ start | stop | restart | status ]

Description

These init scripts are responsible for starting and stopping the three main qmail services. init.d/qmail invokes qmail-start (the main qmail delivery agent), init.d/pop3d invokes qmail-popup, checkpassword, and qmail-pop3d (the POP3 server system for qmail) by way of tcpserver, init.d/qmqpd invokes qmail-qmqpd (the QMQP server for qmail — a specialized null-client protocol) by way of tpcserver, init.d/qmtpd invokes qmail-qmtpd (the QMTP server for qmail — a high-speed alternative to SMTP) by way of tcpserver, and init.d/smtpd invokes qmail-smtpd (the SMTP daemon for qmail) by way of tcpserver, as well as optionally invoking rblsmtpd if that package is installed.

These files typically reside in either /etc/rc.d/init.d (most systems using SysV-style init scripts) or /etc/init.d (Solaris).

Control Files

aliasempty

Default delivery instructions. Default: ./Mailbox. The contents of this file are used as the default delivery instructions for any legitimate local address that has either nonexistant or empty delivery instructions. See dot-qmail(5) for details on the contents. To emulate the typical sendmail and procmail combined configuration, install the dot-forward and procmail packages (and ensure they and preline are in the path), and put the following lines in this file: |dot-forward .forward
|preline procmail
antirbldomains
If antirbl is installed, this file contains a list of domains for which to disable RBL testing. Default: empty.
checkpassword
The password checking program for all systems that require one (currently only init.d/pop3d) Default: checkpassword.
concurrencypop3d
Maximum number of simultaneous inbound POP3 connections. Default: 20.
concurrencyqmqpd
Maximum number of simultaneous inbound QMQP connections. Default: 20.
concurrencyqmtpd
Maximum number of simultaneous inbound QMTP connections. Default: 20.
concurrencysmtpd
Maximum number of simultaneous inbound SMTP connections. Default: 20.
logger
The program that is to be used for message logging. Default: splogger. It is started in the /var/log directory. If the string contains {}, then it replaced with the name of the system being logged (such as qmail or pop3d), otherwise the system name is appended to the string. To use multilog ensure that a subdirectory in /var/log exists for each of the systems and put the following in this file: multilog -t {}
rbldomains
If rblsmtpd is installed, this file lists the RBL domain servers on which to do lookups. Default: rbl.maps.vix.com.
rbltimeout
If rblsmtpd is installed, this file sets the timeout value. Default: 60.
ulimitcpu
The maximum amount of CPU time an individual daemon process (pop3d, qmqpd, qmtpd, or smtpd) is allowed to consume before it is terminated, in seconds. Default: unlimited.
ulimitdata
The maximum data segment size of an individual daemon process, in kilobytes. Default: unlimited.

from: linux.die.net

 

Advertisements

Qmail Queue Stuck: How to Clean Qmail Queue Quickly

Stop Qmail Server Processes for my plesk dedicated server: How to empty qmail queue, how to clean Qmail queue? I rebuilt qmail binaries to implement the mail tap patch, without letting qmail-send stop completely.

Qmail Message Stuck in Queue: How to Clean Qmail Queue Instantly? Solution to this problem as noted from the iflove forum from back in 2008, scripts in this post are currently hosting plesk server at another site to ensure this post stays live and active to help others.

Title: Qmail Queue Stuck: How to Clean Qmail Queue Fast

Keywords: Qmail Queue Stuck, Clean Qmail Queue, Qmail Delete Queue

This post says: Well, first of all, I’ve made a mistake. I’m afraid I rebuilt qmail binaries to implement the mail tap patch, without letting qmail-send stop completely. That caused that about 300 messages are stuck in the queue and didn’t come out neither with qmailctl flush, python queue-repair -r or qmqtool -r. I don’t know what to do, PLEASE HELP ME!!!

QMail incoming mail stuck in queue: This is qmailctl output:

# qmailctl stat
/service/qmail-send: up (pid 49840) 1027 seconds
/service/qmail-send/log: up (pid 49841) 1027 seconds
/service/qmail-smtpd: up (pid 49844) 1027 seconds
/service/qmail-smtpd/log: up (pid 49845) 1027 seconds
/service/qmail-pop3d: up (pid 49850) 1027 seconds
/service/qmail-pop3d/log: up (pid 49852) 1027 seconds
messages in queue: 176
messages in queue but not yet preprocessed: 146

I checked my qmail server today, turns out there are 744 messages stuck in the queue that haven’t been delivered. I’ve tried using qmHandle -a to deliver all of them, but that doesn’t help. I’ve tested an email script that sends out a test email message, and the email is being delivered – with a bit of delay. What about the other emails that are in the queue? I’ve done some extensive reading and I’m still unsure how I can get these messages in the queue to be delivered.

Can anyone help/

Total messages: 744
Messages with local recipients: 0
Messages with remote recipients: 540
Messages with bounces: 0
Messages in preprocess: 0

How to Clear / Clean Qmail Queue Completely, Safely & Fast?

Here is a quick and easy way to clear all email from the queue.
This will not remove anything it should not remove. The script just clears all email from the queue safely and this is ONLY for qmail.
( Note: This is not for use with any other email programs )

Qmail Queue Stuck: How to Clean Qmail Queue Fast CLICK HERE FOR THE UPDATED VERSION!

Clear / clean / empty the qmail queue

1) login to your server via ssh
2) su –
3) wget http://www.japanitup.com/scripts/qmailclear.sh
5) sh qmailclear.sh or sh ./qmailclear.sh
6) done.

For those that receive oversized file truncting errors.
Use the following more intense script. It take a little
longer but gets the job done.

1) login to your server via ssh
2) su –
3) wget http://www.japanitup.com/scripts/qmailclean.sh
5) sh qmailclean.sh or sh ./qmailclean.sh
6) done.

How to empty the qmail queue? To clear *all* messages from the queue, shut down qmail, then:

cd /var/qmail/queue
find intd todo local remote mess info bounce -type f -print |xargs rm

Start qmail back up, and the queue should be empty.

How to empty qmail queue: how to clean Qmail queue? I rebuilt qmail binaries to implement the mail tap patch, without letting qmail-send stop completely. I hope this has helped others out! Any different idea?

Quoted from: website.iflove.com